HDESK
hdeskCurrent;
HDESK hdesk;
HWINSTA hwinstaCurrent;
HWINSTA
hwinsta;
hwinstaCurrent = GetProcessWindowStation();
hdeskCurrent =
GetThreadDesktop(GetCurrentThreadId());
//打开用户的winsta0
hwinsta =
OpenWindowStation("winsta0", FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS
|
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE
|
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN
|
WINSTA_WRITEATTRIBUTES);
//打开desktop
hdesk = OpenDesktop("default", 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE
|
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD
|
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP
|
DESKTOP_WRITEOBJECTS);
SetThreadDesktop(hdesk);
ShellExecute(0,NULL,"D://test.exe",NULL,NULL,SW_HIDE);
SetProcessWindowStation(hwinstaCurrent);
SetThreadDesktop(hdeskCurrent);
CloseWindowStation(hwinsta);
CloseDesktop(hdesk);