Hello,
i'm using CS for long ago, and this is amazing product.
I have a suggestion to add a graceful remote session disconnect before doing suspend/shutdown/hibernate the machine if it's initiated from remote session.
This prevents from long waiting/force disconnection when PC is controlled over RDP.
Unfortunately, i was not able to download beta sources, just stable one, but i suppose it's not hard to understand what i mean. here is the code (pretty simple):
this goes to ClassicStartMenuDLL\MenuCommands.cpp:
Code:
#define _freeWTS(x) (((x) ? WTSFreeMemory(x):TRUE), (x)=NULL, TRUE)
USHORT getSessionProto()
{
LPVOID wtsProto=NULL;
DWORD wtsInfoSize;
USHORT res=USHRT_MAX;
if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientProtocolType, (LPTSTR *)&wtsProto, &wtsInfoSize))
res=*(PUSHORT)wtsProto;
_freeWTS(wtsProto);
return res;
}
BOOL isConsoleSession()
{
DWORD id1, id2;
USHORT proto;
proto=getSessionProto();
if (proto!=USHRT_MAX)
return (proto==0);
if ((id1=getSessionId())!=ULONG_MAX && (id2=WTSGetActiveConsoleSessionId())!=ULONG_MAX)
return (id1==id2);
return FALSE;
}
static DWORD WINAPI SleepThread(LPVOID state)
{
static LONG inThread=FALSE;
if (!InterlockedCompareExchange(&inThread, TRUE, FALSE))
{
Sleep(250);
if (!isConsoleSession())
{
WTSDisconnectSession(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, TRUE);
Sleep(250);
}
SetSuspendState((state ? TRUE:FALSE), FALSE, FALSE);
InterlockedExchange(&inThread, FALSE);
}
return 0;
}