From 43231a8dbb2b0b4ff3ecfd8415e5bc4e9d9d073e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 8 Jul 2009 19:33:27 +0000 Subject: [PATCH] svn path=/trunk/boinc/; revision=18588 --- lib/win_util.cpp | 20 ++++++++++++++++++++ lib/win_util.h | 1 + 2 files changed, 21 insertions(+) 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();