- client: Fast User Switching does not change the session protocol

to RDP when the active session is put into the background and
        a new one is brought into the foreground.  It appears it is safe
        to use the connected state in addition to the protocol
        to detect when the session is no longer capable of processing
        GPU work
        
    lib/
        win_util.cpp

svn path=/trunk/boinc/; revision=23068
This commit is contained in:
Rom Walton 2011-02-18 20:32:43 +00:00
parent 136085ed6a
commit e8fc714964
2 changed files with 48 additions and 10 deletions

View File

@ -894,3 +894,14 @@ David 17 Feb 2011
gui_rpc_server_ops.cpp
http_curl.cpp
net_stats.cpp,h
Rom 18 Feb 2011
- client: Fast User Switching does not change the session protocol
to RDP when the active session is put into the background and
a new one is brought into the foreground. It appears it is safe
to use the connected state in addition to the protocol
to detect when the session is no longer capable of processing
GPU work
lib/
win_util.cpp

View File

@ -849,7 +849,7 @@ void chdir_to_data_dir() {
// return true if running under remote desktop
// (in which case CUDA apps don't work)
// (in which case CUDA and Stream apps don't work)
//
typedef BOOL (__stdcall *tWTSQSI)( IN HANDLE, IN DWORD, IN DWORD, OUT LPTSTR*, OUT DWORD* );
typedef VOID (__stdcall *tWTSFM)( IN PVOID );
@ -860,6 +860,7 @@ bool is_remote_desktop() {
static tWTSFM pWTSFM = NULL;
LPTSTR pBuf = NULL;
DWORD dwLength;
USHORT usProtocol, usConnectionState;
if (!wtsapi32lib) {
wtsapi32lib = LoadLibrary(_T("wtsapi32.dll"));
@ -869,6 +870,8 @@ bool is_remote_desktop() {
}
}
if (pWTSQSI) {
// WTSQuerySessionInformation(
// WTS_CURRENT_SERVER_HANDLE,
// WTS_CURRENT_SESSION,
@ -876,7 +879,6 @@ bool is_remote_desktop() {
// &pBuf,
// &dwLength
// );
if (pWTSQSI) {
if (pWTSQSI(
(HANDLE)NULL,
(DWORD)-1,
@ -884,10 +886,35 @@ bool is_remote_desktop() {
&pBuf,
&dwLength
)) {
USHORT prot = *(USHORT*)pBuf;
usProtocol = *(USHORT*)pBuf;
pWTSFM(pBuf);
if (prot == 2) return true;
}
// WTSQuerySessionInformation(
// WTS_CURRENT_SERVER_HANDLE,
// WTS_CURRENT_SESSION,
// WTSConnectState,
// &pBuf,
// &dwLength
// );
if (pWTSQSI(
(HANDLE)NULL,
(DWORD)-1,
(DWORD)8,
&pBuf,
&dwLength
)) {
usConnectionState = *(USHORT*)pBuf;
pWTSFM(pBuf);
}
// RDP Session implies Remote Desktop
if (usProtocol == 2) return true;
// Fast User Switching keeps the protocol set to the console but changes
// the connected state to disconnected.
if ((usProtocol == 0) && (usConnectionState == 4)) return true;
}
return false;