Catched exception while getting active desktop name
This commit is contained in:
parent
5833b434ef
commit
e71e7e1cd3
|
@ -176,15 +176,19 @@ String
|
||||||
MSWindowsSession::getActiveDesktopName()
|
MSWindowsSession::getActiveDesktopName()
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
try {
|
||||||
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
||||||
if (hd != NULL) {
|
if (hd != NULL) {
|
||||||
DWORD size;
|
DWORD size;
|
||||||
GetUserObjectInformation(hd, UOI_NAME, NULL, 0, &size);
|
GetUserObjectInformation(hd, UOI_NAME, NULL, 0, &size);
|
||||||
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
|
TCHAR* name = (TCHAR*)alloca(size + sizeof(TCHAR));
|
||||||
GetUserObjectInformation(hd, UOI_NAME, name, size, &size);
|
GetUserObjectInformation(hd, UOI_NAME, name, size, &size);
|
||||||
result = name;
|
result = name;
|
||||||
CloseDesktop(hd);
|
CloseDesktop(hd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception error) {
|
||||||
|
LOG((CLOG_ERR "failed to get active desktop name: %s", error.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue