I am working on an application that records a screen and it should support terminal services. The problem actually is that the RDP window is minimized when the user session goes into less than UI mode and there is no screen to capture the application in this particular session.
There is a way to handle this by setting the registry value to store the user interface as described here .
But I do not want to do this and would like to capture the status of the mode less than the UI and display a message to the user that the RDP window has been minimized / fast user switch, and recording is paused.
So, I decided to list the active sessions and check if the user's session is either inactive or limited by the user. But that does not help. I did not find any information about finding a quick user switch when the RDP window is minimized after almost spending a day.
I could not find any event or API that I could call to ensure that the screen capture was unsuccessful due to the quick user / minimized RDP window switching.
Here is my code
bool bActive = false;
{
DWORD dwCurrentProcessSessionID = 0;
ProcessIdToSessionId(GetCurrentProcessId(), &dwCurrentProcessSessionID);
PWTS_SESSION_INFO pSessionInfo = 0;
DWORD dwCount = 0;
WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo, &dwCount);
int dataSize = sizeof(WTS_SESSION_INFO);
for (DWORD i = 0; i < dwCount; ++i)
{
WTS_SESSION_INFO si = pSessionInfo[i];
if (_WTS_CONNECTSTATE_CLASS::WTSActive == si.State)
{
if (dwCurrentProcessSessionID == si.SessionId)
{
if (FunctionToFindCurrentRDPIsUIless(si.SessionId))
{
bActive = false;
}
else
{
bActive = true;
}
break;
}
}
}
}
Any help would be appreciated.
source
share