首页 > 代码库 > 创建虚拟桌面的代码(重启桌面进程)(使用GetThreadDesktop,CreateDesktop,SetThreadDesktop等函数)

创建虚拟桌面的代码(重启桌面进程)(使用GetThreadDesktop,CreateDesktop,SetThreadDesktop等函数)

在upk 里挖坟得来,有兴趣查查这几个函数...

 

 

[cpp] view plain copy
 
 print?
  1. #include "windows.h"  
  2. #pragma comment(lib,"user32.lib")  
  3. int main()  
  4. {  
  5.     STARTUPINFO si;  
  6.     PROCESS_INFORMATION pi;  
  7.     char DeskName[]="pp";  
  8.     HDESK hold = GetThreadDesktop(GetCurrentThreadId());  
  9.     HDESK hhdesk = CreateDesktop( DeskName, NULL, NULL, DF_ALLOWOTHERACCOUNTHOOK, GENERIC_ALL, NULL);  
  10.     SwitchDesktop( hhdesk);  
  11.     SetThreadDesktop( hhdesk);  
  12.     ZeroMemory( &si, sizeof(si) );    
  13.     si.cb = sizeof(si);     
  14.     si.lpDesktop = DeskName;  
  15.     ZeroMemory( π, sizeof(pi) );    
  16.     CreateProcess( NULL, "explorer", NULL, NULL, FALSE, 0, NULL, NULL, &si, π);  
  17.     Sleep(60000);  
  18.     SwitchDesktop( hold);  
  19.     CloseDesktop( hhdesk);  
  20. }  

 

 

http://blog.csdn.net/wangningyu/article/details/5179221

创建虚拟桌面的代码(重启桌面进程)(使用GetThreadDesktop,CreateDesktop,SetThreadDesktop等函数)