From a4f47f8fad7d02b961c655cc0495f7ecc8c82a78 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 31 Jan 2014 02:06:08 +0000 Subject: Adding functions that will allow us to be more specific about the elevation event --HG-- branch : elevation --- windirstat/osspecific.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- windirstat/osspecific.h | 2 ++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/windirstat/osspecific.cpp b/windirstat/osspecific.cpp index cec839d..a368467 100644 --- a/windirstat/osspecific.cpp +++ b/windirstat/osspecific.cpp @@ -58,5 +58,45 @@ BOOL FileIconInit(__in BOOL fRestoreCache) { return pfnFileIconInit(fRestoreCache); } - return TRUE; + return FALSE; } + +CString GetCurrentDesktopName() +{ + if(HDESK hDesktop = ::GetThreadDesktop(::GetCurrentThreadId())) + { + DWORD dwNeeded = 0; + if(!::GetUserObjectInformation(hDesktop, UOI_NAME, NULL, 0, &dwNeeded) && dwNeeded) + { + CString retval; + dwNeeded /= sizeof(TCHAR) + 1; + LPTSTR buf = retval.GetBuffer(dwNeeded); + if(::GetUserObjectInformation(hDesktop, UOI_NAME, buf, dwNeeded, &dwNeeded)) + { + retval.ReleaseBuffer(); + return retval; + } + } + } + return CString(); +} + +CString GetCurrentWinstaName() +{ + if(HWINSTA hWinsta = GetProcessWindowStation()) + { + DWORD dwNeeded = 0; + if(!GetUserObjectInformation(hWinsta, UOI_NAME, NULL, 0, &dwNeeded) && dwNeeded) + { + CString retval; + dwNeeded /= sizeof(TCHAR) + 1; + LPTSTR buf = retval.GetBuffer(dwNeeded); + if(GetUserObjectInformation(hWinsta, UOI_NAME, buf, dwNeeded, &dwNeeded)) + { + retval.ReleaseBuffer(); + return retval; + } + } + } + return CString(); +} diff --git a/windirstat/osspecific.h b/windirstat/osspecific.h index f4d7886..8e09fc4 100644 --- a/windirstat/osspecific.h +++ b/windirstat/osspecific.h @@ -30,6 +30,8 @@ #include BOOL FileIconInit(__in BOOL fRestoreCache); +CString GetCurrentDesktopName(); +CString GetCurrentWinstaName(); class CAbstractionLayer { -- cgit v1.2.3