mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-11 14:15:46 +08:00
Catched exception while getting active desktop name
This commit is contained in:
@@ -176,15 +176,19 @@ String
|
||||
MSWindowsSession::getActiveDesktopName()
|
||||
{
|
||||
String result;
|
||||
|
||||
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
||||
if (hd != NULL) {
|
||||
DWORD size;
|
||||
GetUserObjectInformation(hd, UOI_NAME, NULL, 0, &size);
|
||||
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
|
||||
GetUserObjectInformation(hd, UOI_NAME, name, size, &size);
|
||||
result = name;
|
||||
CloseDesktop(hd);
|
||||
try {
|
||||
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
||||
if (hd != NULL) {
|
||||
DWORD size;
|
||||
GetUserObjectInformation(hd, UOI_NAME, NULL, 0, &size);
|
||||
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
|
||||
GetUserObjectInformation(hd, UOI_NAME, name, size, &size);
|
||||
result = name;
|
||||
CloseDesktop(hd);
|
||||
}
|
||||
}
|
||||
catch (std::exception error) {
|
||||
LOG((CLOG_ERR "failed to get active desktop name: %s", error.what()));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user