mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Code style change and rebuild zstd with optimization options
This commit is contained in:
@@ -110,75 +110,75 @@ BOOL SelectHDESK(HDESK new_desktop)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HDESK OpenActiveDesktop(ACCESS_MASK dwDesiredAccess) {
|
||||
if (dwDesiredAccess == 0) {
|
||||
dwDesiredAccess = DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS;
|
||||
}
|
||||
HDESK OpenActiveDesktop(ACCESS_MASK dwDesiredAccess)
|
||||
{
|
||||
if (dwDesiredAccess == 0) {
|
||||
dwDesiredAccess = DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS;
|
||||
}
|
||||
|
||||
HDESK hInputDesktop = OpenInputDesktop(0, FALSE, dwDesiredAccess);
|
||||
HDESK hInputDesktop = OpenInputDesktop(0, FALSE, dwDesiredAccess);
|
||||
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenInputDesktop failed: %d, trying Winlogon\n", GetLastError());
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenInputDesktop failed: %d, trying Winlogon\n", GetLastError());
|
||||
|
||||
HWINSTA hWinSta = OpenWindowStation("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
||||
if (hWinSta) {
|
||||
SetProcessWindowStation(hWinSta);
|
||||
hInputDesktop = OpenDesktop("Winlogon", 0, FALSE, dwDesiredAccess);
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenDesktop Winlogon failed: %d, trying Default\n", GetLastError());
|
||||
hInputDesktop = OpenDesktop("Default", 0, FALSE, dwDesiredAccess);
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenDesktop Default failed: %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mprintf("OpenWindowStation failed: %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
return hInputDesktop;
|
||||
HWINSTA hWinSta = OpenWindowStation("WinSta0", FALSE, WINSTA_ALL_ACCESS);
|
||||
if (hWinSta) {
|
||||
SetProcessWindowStation(hWinSta);
|
||||
hInputDesktop = OpenDesktop("Winlogon", 0, FALSE, dwDesiredAccess);
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenDesktop Winlogon failed: %d, trying Default\n", GetLastError());
|
||||
hInputDesktop = OpenDesktop("Default", 0, FALSE, dwDesiredAccess);
|
||||
if (!hInputDesktop) {
|
||||
Mprintf("OpenDesktop Default failed: %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Mprintf("OpenWindowStation failed: %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
return hInputDesktop;
|
||||
}
|
||||
|
||||
// 返回新桌面句柄,如果没有变化返回NULL
|
||||
HDESK IsDesktopChanged(HDESK currentDesk, DWORD accessRights) {
|
||||
HDESK hInputDesk = OpenActiveDesktop(accessRights);
|
||||
if (!hInputDesk) return NULL;
|
||||
HDESK IsDesktopChanged(HDESK currentDesk, DWORD accessRights)
|
||||
{
|
||||
HDESK hInputDesk = OpenActiveDesktop(accessRights);
|
||||
if (!hInputDesk) return NULL;
|
||||
|
||||
if (!currentDesk) {
|
||||
return hInputDesk;
|
||||
}
|
||||
else {
|
||||
// 通过桌面名称判断是否真正变化
|
||||
char oldName[256] = { 0 };
|
||||
char newName[256] = { 0 };
|
||||
DWORD len = 0;
|
||||
GetUserObjectInformationA(currentDesk, UOI_NAME, oldName, sizeof(oldName), &len);
|
||||
GetUserObjectInformationA(hInputDesk, UOI_NAME, newName, sizeof(newName), &len);
|
||||
if (!currentDesk) {
|
||||
return hInputDesk;
|
||||
} else {
|
||||
// 通过桌面名称判断是否真正变化
|
||||
char oldName[256] = { 0 };
|
||||
char newName[256] = { 0 };
|
||||
DWORD len = 0;
|
||||
GetUserObjectInformationA(currentDesk, UOI_NAME, oldName, sizeof(oldName), &len);
|
||||
GetUserObjectInformationA(hInputDesk, UOI_NAME, newName, sizeof(newName), &len);
|
||||
|
||||
if (oldName[0] && newName[0] && strcmp(oldName, newName) != 0) {
|
||||
Mprintf("Desktop changed from '%s' to '%s'\n", oldName, newName);
|
||||
return hInputDesk;
|
||||
}
|
||||
}
|
||||
CloseDesktop(hInputDesk);
|
||||
return NULL;
|
||||
if (oldName[0] && newName[0] && strcmp(oldName, newName) != 0) {
|
||||
Mprintf("Desktop changed from '%s' to '%s'\n", oldName, newName);
|
||||
return hInputDesk;
|
||||
}
|
||||
}
|
||||
CloseDesktop(hInputDesk);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// 桌面切换辅助函数:通过桌面名称比较判断是否需要切换
|
||||
// 返回值:true表示桌面已切换,false表示桌面未变化
|
||||
bool SwitchToDesktopIfChanged(HDESK& currentDesk, DWORD accessRights)
|
||||
{
|
||||
HDESK hInputDesk = IsDesktopChanged(currentDesk, accessRights);
|
||||
HDESK hInputDesk = IsDesktopChanged(currentDesk, accessRights);
|
||||
|
||||
if (hInputDesk) {
|
||||
if (currentDesk) {
|
||||
CloseDesktop(currentDesk);
|
||||
}
|
||||
currentDesk = hInputDesk;
|
||||
SetThreadDesktop(currentDesk);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (hInputDesk) {
|
||||
if (currentDesk) {
|
||||
CloseDesktop(currentDesk);
|
||||
}
|
||||
currentDesk = hInputDesk;
|
||||
SetThreadDesktop(currentDesk);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// - SelectDesktop(char *)
|
||||
|
||||
Reference in New Issue
Block a user