diff --git a/lib/win_util.cpp b/lib/win_util.cpp index 5909f0f5ec..7b876921ff 100644 --- a/lib/win_util.cpp +++ b/lib/win_util.cpp @@ -829,3 +829,23 @@ void chdir_to_data_dir() { if (hkSetupHive) RegCloseKey(hkSetupHive); if (lpszRegistryValue) free(lpszRegistryValue); } + +// return true if running under remote desktop +// (in which case CUDA apps don't work) +// +bool is_remote_desktop() { + LPTSTR *buf; + DWORD len; + if (WTSQuerySessionInformation( + WTS_CURRENT_SERVER_HANDLE, + WTS_CURRENT_SESSION, + WTSClientProtocolType, + &buf, + &len + )) { + USHORT prot = *(USHORT*) buf; + WTSFreeMemory(buf); + if (prot == 2) return true; + } + return false; +} diff --git a/lib/win_util.h b/lib/win_util.h index bf1e0f96cd..8a5141a03a 100644 --- a/lib/win_util.h +++ b/lib/win_util.h @@ -30,3 +30,4 @@ extern BOOL GetAccountSid( ); extern int suspend_or_resume_threads(DWORD pid, bool resume); extern void chdir_to_data_dir(); +extern bool is_remote_desktop();