From af51454e982fd80283cd40e7f62f7c8d727f67af Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 7 Feb 2014 18:03:56 +0000 Subject: [PATCH] fixed: garbage drop target on windows when elevated. --- src/lib/platform/CMSWindowsScreen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/platform/CMSWindowsScreen.cpp b/src/lib/platform/CMSWindowsScreen.cpp index d910b855..04c602eb 100644 --- a/src/lib/platform/CMSWindowsScreen.cpp +++ b/src/lib/platform/CMSWindowsScreen.cpp @@ -147,12 +147,16 @@ CMSWindowsScreen::CMSWindowsScreen( forceShowCursor(); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG((CLOG_DEBUG "window is 0x%08x", m_window)); - - wchar_t* desktopPath = 0; - SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &desktopPath); - m_desktopPath = _bstr_t(desktopPath); - CoTaskMemFree(static_cast(desktopPath)); - LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str())); + + // SHGetFolderPath is deprecated in vista, but use it for xp support. + char desktopPath[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) { + m_desktopPath = CString(desktopPath); + LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str())); + } + else { + LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError())); + } } catch (...) { delete m_keyState;