本文整理汇总了C++中GetThreadDesktop函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadDesktop函数的具体用法?C++ GetThreadDesktop怎么用?C++ GetThreadDesktop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetThreadDesktop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimulateCtrlAltDelThreadFn
void *
SimulateCtrlAltDelThreadFn(void *context)
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
HDESK winlogon_desk = 0;
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon", &winlogon_desk))
{
vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
vncTimedMsgBox::Do(
sz_ID_CADERROR,
sz_ID_ULTRAVNC_WARNING,
MB_ICONINFORMATION | MB_OK
);
return FALSE;
}
// 9 April 2008 jdp
// turn off capslock if on
ClearKeyState(VK_CAPITAL);
vnclog.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
// Fake a hotkey event to any windows we find there.... :(
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
{
vncService::SelectHDESK(old_desktop);
CloseDesktop(winlogon_desk);
}
return NULL;
}
示例2: GetThreadDesktop
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
// Are we running on NT?
if (IsWinNT())
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
DWORD dummy;
char new_name[256];
if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation \n"));
return FALSE;
}
vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, new_desktop, old_desktop);
// Switch the desktop
if(!SetThreadDesktop(new_desktop)) {
vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop \n"));
return FALSE;
}
return TRUE;
}
return TRUE;
}
示例3: GetThreadDesktop
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
// Are we running on NT?
if (IsWinNT())
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
DWORD dummy;
char new_name[256];
if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
return FALSE;
}
// Switch the desktop
if(!SetThreadDesktop(new_desktop)) {
return FALSE;
}
// Switched successfully - destroy the old desktop
CloseDesktop(old_desktop);
return TRUE;
}
return TRUE;
}
示例4: SwitchInputDesktop
bool SwitchInputDesktop()
{
BOOL bRet = false;
DWORD dwLengthNeeded;
HDESK hOldDesktop, hNewDesktop;
char strCurrentDesktop[256], strInputDesktop[256];
hOldDesktop = GetThreadDesktop(GetCurrentThreadId());
memset(strCurrentDesktop, 0, sizeof(strCurrentDesktop));
GetUserObjectInformation(hOldDesktop, UOI_NAME, &strCurrentDesktop, sizeof(strCurrentDesktop), &dwLengthNeeded);
hNewDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
memset(strInputDesktop, 0, sizeof(strInputDesktop));
GetUserObjectInformation(hNewDesktop, UOI_NAME, &strInputDesktop, sizeof(strInputDesktop), &dwLengthNeeded);
if (lstrcmpi(strInputDesktop, strCurrentDesktop) != 0)
{
SetThreadDesktop(hNewDesktop);
bRet = true;
}
CloseDesktop(hOldDesktop);
CloseDesktop(hNewDesktop);
return bRet;
}
示例5: InputDesktopSelected
bool InputDesktopSelected()
{
DWORD dummy;
char threadname[256];
char inputname[256];
HDESK threaddesktop = GetThreadDesktop(GetCurrentThreadId());
HDESK inputdesktop = OpenInputDesktop(0, FALSE,
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
if (inputdesktop == NULL) return FALSE;
if (!GetUserObjectInformation(threaddesktop, UOI_NAME, &threadname, 256, &dummy)) {
CloseDesktop(inputdesktop);
return FALSE;
}
if (!GetUserObjectInformation(inputdesktop, UOI_NAME, &inputname, 256, &dummy)) {
CloseDesktop(inputdesktop);
return FALSE;
}
CloseDesktop(inputdesktop);
if (strcmp(threadname, inputname) != 0)
{
//if (strcmp(inputname, "Screen-saver") == 0)
{
return SelectDesktop();
}
return FALSE;
}
return TRUE;
}
示例6: GetThreadDesktop
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
// Are we running on NT?
if (IsWinNT())
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
//You do not need to call the CloseDesktop function to close the returned handle.
DWORD dummy;
char new_name[256];
if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
return FALSE;
}
//vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, new_desktop, old_desktop);
// Switch the desktop
if(!SetThreadDesktop(new_desktop))
{
return FALSE;
}
return TRUE;
}
return TRUE;
}
示例7: Process_Desktop
/*************************************************
* Create a new Desktop and run a Process in it. *
* (Win NT+). *
*************************************************/
int DLL_EXP_IMP WINAPI Process_Desktop(char *szDesktopName, char *szPath)
{
HDESK hOriginalThread;
HDESK hOriginalInput;
HDESK hNewDesktop;
// Save original ...
hOriginalThread = GetThreadDesktop(GetCurrentThreadId());
hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
// Create a new Desktop and switch to it
hNewDesktop = CreateDesktop(szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL);
SetThreadDesktop(hNewDesktop);
SwitchDesktop(hNewDesktop);
// Execute process in new desktop
StartProcess(szDesktopName, szPath);
// Restore original ...
SwitchDesktop(hOriginalInput);
SetThreadDesktop(hOriginalThread);
// Close the Desktop
CloseDesktop(hNewDesktop);
return 0;
}
示例8: SimulateCtrlAltDelThreadFn
void *
SimulateCtrlAltDelThreadFn(void *context)
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon"))
{
vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
return FALSE;
}
vnclog.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
HWND hwndCtrlAltDel = FindWindow("SAS window class", "SAS window");
if (hwndCtrlAltDel == NULL) {
vnclog.Print(LL_INTERR, VNCLOG("\"SAS window\" not found\n"));
hwndCtrlAltDel = HWND_BROADCAST;
}
PostMessage(hwndCtrlAltDel, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
vncService::SelectHDESK(old_desktop);
return NULL;
}
示例9: SelectDesktop
bool SelectDesktop()
{
HDESK desktop;
HDESK old_desktop;
DWORD dummy;
char new_name[256];
desktop = OpenInputDesktop(0, FALSE,
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
if (desktop == NULL) return FALSE;
old_desktop = GetThreadDesktop(GetCurrentThreadId());
if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy)) {
CloseDesktop(desktop);
return FALSE;
}
if(!SetThreadDesktop(desktop)) {
CloseDesktop(desktop);
return FALSE;
}
CloseDesktop(old_desktop);
return TRUE;
}
示例10: SimulateCtrlAltDelThreadFn
void SimulateCtrlAltDelThreadFn()
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon"))
{
//vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
Log.WinError(_ERROR_, "failed to select logon desktop");
if (!vncService::SelectDesktop("Default"))
{
Log.WinError(_ERROR_, "failed to select default desktop");
}
}
//vnclog.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
// Fake a hotkey event to any windows we find there.... :(
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
vncService::SelectHDESK(old_desktop);
}
示例11: sizeof
/* retrieve the desktop name to use if not specified on the command line */
static const WCHAR *get_default_desktop_name(void)
{
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0};
static const WCHAR explorer_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
'E','x','p','l','o','r','e','r',0};
static WCHAR buffer[MAX_PATH];
DWORD size = sizeof(buffer);
HDESK desk = GetThreadDesktop( GetCurrentThreadId() );
WCHAR *ret = NULL;
HKEY hkey;
if (desk && GetUserObjectInformationW( desk, UOI_NAME, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
{
if (strcmpiW( buffer, defaultW )) return buffer;
}
/* @@ Wine registry key: HKCU\Software\Wine\Explorer */
if (!RegOpenKeyW( HKEY_CURRENT_USER, explorer_keyW, &hkey ))
{
if (!RegQueryValueExW( hkey, desktopW, 0, NULL, (LPBYTE)buffer, &size )) ret = buffer;
RegCloseKey( hkey );
}
return ret;
}
示例12: Thread_Desktop
/************************************************
* Create a new Desktop and run a Thread in it. *
* (Win NT+). *
************************************************/
int DLL_EXP_IMP WINAPI Thread_Desktop(LPTHREAD_START_ROUTINE ThreadFunc, THREAD_DATA *td)
{
HDESK hOriginalThread;
HDESK hOriginalInput;
HDESK hNewDesktop;
// Save original ...
hOriginalThread = GetThreadDesktop(GetCurrentThreadId());
hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
// Create a new Desktop and switch to it
hNewDesktop = CreateDesktop(td->szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL);
SetThreadDesktop(hNewDesktop);
SwitchDesktop(hNewDesktop);
// Execute thread in new desktop
td->hDesk = hNewDesktop;
StartThread(ThreadFunc, td);
// Restore original ...
SwitchDesktop(hOriginalInput);
SetThreadDesktop(hOriginalThread);
// Close the Desktop
CloseDesktop(hNewDesktop);
return 0;
}
示例13: do_InitialDesktop_child
void do_InitialDesktop_child(int i)
{
HDESK hdesktop;
HWINSTA hwinsta;
WCHAR buffer[100];
DWORD size;
BOOL ret;
if(TestResults[i].ExpectedWinsta == NULL)
{
trace("Process should have failed to initialize\n");
return;
}
IsGUIThread(TRUE);
hdesktop = GetThreadDesktop(GetCurrentThreadId());
hwinsta = GetProcessWindowStation();
ret = GetUserObjectInformationW( hwinsta, UOI_NAME, buffer, sizeof(buffer), &size );
ok(ret == TRUE, "ret = %d\n", ret);
ok(wcscmp(buffer, TestResults[i].ExpectedWinsta) == 0, "Wrong winsta %S insted of %S\n", buffer, TestResults[i].ExpectedWinsta);
ret = GetUserObjectInformationW( hdesktop, UOI_NAME, buffer, sizeof(buffer), &size );
ok(ret == TRUE, "ret = %d\n", ret);
ok(wcscmp(buffer, TestResults[i].ExpectedDesktp) == 0, "Wrong desktop %S insted of %S\n", buffer, TestResults[i].ExpectedDesktp);
}
示例14: GetThreadDesktop
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
// Are we running on NT?
if (IsWinNT())
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
DWORD dummy;
char new_name[256];
if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
vnclog.Print(LL_INTERR, VNCLOG("GetUserObjectInformation() failed\n"));
return FALSE;
}
vnclog.Print(LL_INTINFO, VNCLOG("SelectHDESK() to %s (%x) from %x\n"),
new_name, new_desktop, old_desktop);
// Switch the desktop
if(!SetThreadDesktop(new_desktop)) {
vnclog.Print(LL_INTERR, VNCLOG("unable to SetThreadDesktop(), error=%d\n"), GetLastError());
return FALSE;
}
// Switched successfully - destroy the old desktop
if (!CloseDesktop(old_desktop))
vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK failed to close old desktop %x, error=%d\n"), old_desktop, GetLastError());
return TRUE;
}
return TRUE;
}
示例15: SetUserDesktop
int SetUserDesktop( int mode )
{
static HWINSTA hwinstaSave;
static HDESK hdeskSave;
static HWINSTA hwinstaUser;
static HDESK hdeskUser;
if(mode == 1) {
hwinstaSave = GetProcessWindowStation();
hdeskSave = GetThreadDesktop(GetCurrentThreadId());
hwinstaUser = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);
if (hwinstaUser == NULL)
return 0;
SetProcessWindowStation(hwinstaUser);
hdeskUser = OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED);
if (hdeskUser == NULL) {
SetProcessWindowStation(hwinstaSave);
CloseWindowStation(hwinstaUser);
return 0;
}
SetThreadDesktop(hdeskUser);
}
else if(mode == 0) {
SetThreadDesktop(hdeskSave);
SetProcessWindowStation(hwinstaSave);
CloseDesktop(hdeskUser);
CloseWindowStation(hwinstaUser);
}
return 0;
}