Çë½ÌÐéÄâ×ÀÃæµÄ³ÌÐò
ÏëÓÃCÀ´Ð´Ò»¸öÐéÄâ×ÀÃæµÄ³ÌÐò£¬µ«ÊÇÒÔÎÒѧµÄ֪ʶ¿´²»¶®´ÓÍøÉϵ±ÏÂÀ´µÄ´úÂ룬Çë½Ì¸÷λ¸ßÊÖÈçºÎÒÔ¼òµ¥µÄ´úÂëʵÏÖ£¡¡¡#include<afxwin.h>
HINSTANCE hInst;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //µ±Ç°ÊµÀý
TCHAR szAppName[] = TEXT ("VirtualDesk") ;¡¡¡¡¡¡¡¡¡¡ //³ÌÐòÃû³Æ
HWND¡¡ hwnd ;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Ö÷´°Ìå¾ä±ú
HDESK hVirtualDesk;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÐéÄâ×ÀÃæ¾ä±ú
HDESK hCurrent;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //µ±Ç°×ÀÃæ¾ä±ú
PROCESS_INFORMATION piExplor;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Explorer½ø³ÌµÄPROCESS_INFORMATION½á¹¹
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
//ÿ´ÎÔËÐÐÊ×Ïȼì²â×¢²á±íÏà¹ØÏÈç¹ûδ·¢ÏÖ£¬ÔòÉèÖÿª»ú×Ô¶¯ÔËÐÐ
void SetStartup(HINSTANCE hInst)
{
¡¡¡¡¡¡ HKEY hKey;
¡¡¡¡¡¡ DWORD DataType = REG_SZ;
¡¡¡¡¡¡ PCSTR data_run = "Software\Microsoft\Windows\CurrentVersion\Run";
¡¡¡¡¡¡ long ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_run,0,KEY_ALL_ACCESS,&hKey);
¡¡¡¡¡¡ if(ret != ERROR_SUCCESS)
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ MessageBox(NULL,"ÎÞ·¨´ò¿ª×¢²á±í¼ü","Error",0);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return;
¡¡¡¡¡¡ }
¡¡¡¡¡¡ CString ProcessName;
¡¡¡¡¡¡ int len = GetModuleFileName(hInst,ProcessName.GetBuffer(256),256);
¡¡¡¡¡¡¡¡¡¡ if(len == 0)
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ MessageBox(NULL,"ÎÞ·¨»ñÈ¡½ø³ÌµÄµ±Ç°Ä¿Â¼","Error",0);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return;
¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡ ProcessName.ReleaseBuffer(len);
¡¡¡¡¡¡¡¡¡¡ DWORD direcLen = ProcessName.GetLength() + 1;
¡¡¡¡¡¡¡¡¡¡ LPBYTE direc = new BYTE[direcLen];
¡¡¡¡¡¡ ZeroMemory(direc,direcLen);
¡¡¡¡¡¡¡¡¡¡ ret = RegQueryValueEx(hKey,"VirtualDesk",0,0,direc,&direcLen);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Èç¹û¼ü²»´æÔÚ»òÕß¼ü³¤¶ÈÓëĿǰµÄÖµ³¤¶È²»Æ¥ÅäÔòÌí¼Óмü
¡¡¡¡¡¡¡¡¡¡ if((ret != ERROR_SUCCESS )|| (direcLen != ProcessName.GetLength()+1))
¡¡¡¡¡¡ {
SetValue:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ DWORD KeyLength = ProcessName.GetLength() + 1;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ LPBYTE KeyValue = new BYTE[KeyLength];
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ZeroMemory(KeyValue,KeyLength);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ for(int i=0;i<ProcessName.GetLength();i++)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ KeyValue[i] = ProcessName[i];
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ KeyValue[ProcessName.GetLength()] = 0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ret = RegSetValueEx(hKey,"VirtualDesk",0,REG_SZ,KeyValue,KeyLength);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ delete []KeyValue;
¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡ else
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Èç¹û¼üµÄÄÚÈÝÓ뵱ǰֵ²»Æ¥ÅäͬÑù½øÐиü¸Ä
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ for(int i=0;i<ProcessName.GetLength();i++)
¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(direc[i] != ProcessName[i])
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ goto SetValue;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡ }
¡¡¡¡¡¡ delete []direc;
¡¡¡¡¡¡ return;
}
//´´½¨explorer½ø³ÌµÄº¯Êý£¬Èç¹û´´½¨ÁËÒ»¸öÐéÄâ×ÀÃæ£¬ÄÇô×îºÃµ÷Óøú¯Êý
void StartExplorer()
{
¡¡¡¡¡¡ STARTUPINFO si;
¡¡¡¡¡¡ ZeroMemory( &si, sizeof(si) );
¡¡¡¡¡¡ si.cb = sizeof(si);
¡¡¡¡¡¡ si.lpDesktop = "Virtual";
¡¡¡¡¡¡ ZeroMemory( &piExplor, sizeof(piExplor) );
¡¡¡¡¡¡ if( !CreateProcess( NULL,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // No module name (use command line).
¡¡¡¡¡¡ "explorer",¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Command line.
¡¡¡¡¡¡ NULL,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Process handle not inheritable.
¡¡¡¡¡¡ NULL,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Thread handle not inheritable.
¡¡¡¡¡¡ FALSE,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Set handle inheritance to FALSE.
¡¡¡¡¡¡ 0,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // No creation flags.
¡¡¡¡¡¡ NULL,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Use parent's environment block.
¡¡¡¡¡¡ NULL,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Use parent's starting directory.
¡¡¡¡¡¡ &si,¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Pointer to STARTUPINFO structure.
¡¡¡¡¡¡ &piExplor )¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ // Pointer to PROCESS_INFORMATION structure.
¡¡¡¡¡¡ )
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ MessageBox(NULL,"ÎÞ·¨³õʼ»¯Explorer","Error",0);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ExitProcess(1);
¡¡¡¡¡¡ }
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
¡¡¡¡¡¡ WNDCLASSEX wcex;
¡¡¡¡¡¡ wcex.cbSize = sizeof(WNDCLASSEX);
¡¡¡¡¡¡ wcex.style¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ = CS_HREDRAW | CS_VREDRAW;
¡¡¡¡¡¡ wcex.lpfnWndProc¡¡¡¡¡¡ = (WNDPROC)WndProc;
¡¡¡¡¡¡ wcex.cbClsExtra¡¡¡¡¡¡¡¡ = 0;
¡¡¡¡¡¡ wcex.cbWndExtra¡¡¡¡¡¡¡¡ = 0;
¡¡¡¡¡¡ wcex.hInstance¡¡¡¡¡¡¡¡¡¡ = hInstance;
¡¡¡¡¡¡ wcex.hIcon¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);
¡¡¡¡¡¡ wcex.hCursor¡¡¡¡¡¡¡¡¡¡¡¡¡¡ = LoadCursor(NULL, IDC_ARROW);
¡¡¡¡¡¡ wcex.hbrBackground¡¡ = (HBRUSH)(COLOR_WINDOW+1);
¡¡¡¡¡¡ wcex.lpszMenuName¡¡¡¡ = NULL;
¡¡¡¡¡¡ wcex.lpszClassName¡¡ = szAppName;
¡¡¡¡¡¡ wcex.hIconSm¡¡¡¡¡¡¡¡¡¡¡¡¡¡ = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_APPLICATION);
¡¡¡¡¡¡ return RegisterClassEx(&wcex);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
¡¡¡¡ hInst = hInstance; // ½«ÊµÀý¾ä±ú´æ´¢ÔÚÈ«¾Ö±äÁ¿ÖÐ
¡¡¡¡ hwnd = CreateWindow(szAppName, TEXT ("SunBear"), WS_OVERLAPPEDWINDOW,
¡¡¡¡¡¡¡¡¡¡ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
¡¡¡¡ if (!hwnd)
¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡ return FALSE;
¡¡¡¡ }
¡¡¡¡ return TRUE;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
¡¡¡¡¡¡ static TCHAR szAppName[] = TEXT ("SunBear") ;
¡¡¡¡¡¡ MSG¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ msg ;
¡¡¡¡¡¡ SetStartup(hInstance);
¡¡¡¡¡¡ hVirtualDesk = CreateDesktop(
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ "Virtual",
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ DF_ALLOWOTHERACCOUNTHOOK,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ GENERIC_ALL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL);
¡¡¡¡¡¡ hCurrent = GetThreadDesktop(GetCurrentThreadId());
¡¡¡¡¡¡ MyRegisterClass(hInstance);
¡¡¡¡¡¡ if (!InitInstance (hInstance, iCmdShow))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return FALSE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡ StartExplorer();¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Æô¶¯Explorer½ø³Ì
¡¡¡¡¡¡ if(!RegisterHotKey(hwnd, 0x0001,MOD_ALT ,'Q'))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //´¦ÀíÇл»ÐéÄâ×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return TRUE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡ if(!RegisterHotKey(hwnd, 0x0002, 0,VK_F8))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //´¦ÀíÍ˳ö½ø³Ì
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return TRUE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ while (GetMessage (&msg, NULL, 0, 0))
¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ TranslateMessage (&msg) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ DispatchMessage (&msg) ;
¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ return 0;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
¡¡¡¡¡¡¡¡ HDC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hdc ;
¡¡¡¡¡¡¡¡ PAINTSTRUCT ps ;
¡¡¡¡¡¡¡¡ static HDESK hNow = hCurrent;
¡¡¡¡¡¡¡¡ switch (message)
¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡ case WM_PAINT:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hdc = BeginPaint (hwnd, &ps) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ EndPaint (hwnd, &ps) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0 ;
¡¡¡¡¡¡¡¡ case WM_DESTROY:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÔڹرÕÐéÄâ×ÀÃæÇ°ÒªÇл»»Øµ±Ç°×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hCurrent);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ PostQuitMessage (0) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0 ;
¡¡¡¡¡¡¡¡ case WM_HOTKEY:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(0x0001 == wParam)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(hNow == hCurrent)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hVirtualDesk);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hNow = hVirtualDesk;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ else
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hCurrent);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hNow = hCurrent;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(0x0002 == wParam)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÓÃTerminateProcessÖÕÖ¹explorer½ø³ÌµÄʱºò£¬Èç¹û´«µÝµÚ¶þ¸ö²ÎÊýΪ1
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÄÇô²Ù×÷ϵͳ²»»áÔÚÖÕÖ¹ºó×Ô¶¯»½ÐÑexplorer,Èç¹ûΪ0,»áÖØÐÂÆô¶¯
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //explorer
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ TerminateProcess(piExplor.hProcess,1);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //¹Ø±ÕÐéÄâ×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ CloseDesktop(hVirtualDesk);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SendMessage(hwnd,WM_CLOSE,0,0);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0;
¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ return DefWindowProc (hwnd, message, wParam, lParam) ;
}
¡¡int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
¡¡¡¡¡¡ static TCHAR szAppName[] = TEXT ("SunBear") ;
¡¡¡¡¡¡ MSG¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ msg ;
¡¡¡¡¡¡ SetStartup(hInstance);
¡¡¡¡¡¡ hVirtualDesk = CreateDesktop(
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ "Virtual",
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ DF_ALLOWOTHERACCOUNTHOOK,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ GENERIC_ALL,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ NULL);
¡¡¡¡¡¡ hCurrent = GetThreadDesktop(GetCurrentThreadId());
¡¡¡¡¡¡ MyRegisterClass(hInstance);
¡¡¡¡¡¡ if (!InitInstance (hInstance, iCmdShow))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return FALSE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡ StartExplorer();¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //Æô¶¯Explorer½ø³Ì
¡¡¡¡¡¡ if(!RegisterHotKey(hwnd, 0x0001,MOD_ALT ,'Q'))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //´¦ÀíÇл»ÐéÄâ×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return TRUE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡ if(!RegisterHotKey(hwnd, 0x0002, 0,VK_F8))
¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //´¦ÀíÍ˳ö½ø³Ì
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return TRUE;
¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ while (GetMessage (&msg, NULL, 0, 0))
¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ TranslateMessage (&msg) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ DispatchMessage (&msg) ;
¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ return 0;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
¡¡¡¡¡¡¡¡ HDC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hdc ;
¡¡¡¡¡¡¡¡ PAINTSTRUCT ps ;
¡¡¡¡¡¡¡¡ static HDESK hNow = hCurrent;
¡¡¡¡¡¡¡¡ switch (message)
¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡ case WM_PAINT:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hdc = BeginPaint (hwnd, &ps) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ EndPaint (hwnd, &ps) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0 ;
¡¡¡¡¡¡¡¡ case WM_DESTROY:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÔڹرÕÐéÄâ×ÀÃæÇ°ÒªÇл»»Øµ±Ç°×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hCurrent);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ PostQuitMessage (0) ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0 ;
¡¡¡¡¡¡¡¡ case WM_HOTKEY:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(0x0001 == wParam)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(hNow == hCurrent)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hVirtualDesk);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hNow = hVirtualDesk;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ else
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SwitchDesktop(hCurrent);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hNow = hCurrent;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(0x0002 == wParam)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÓÃTerminateProcessÖÕÖ¹explorer½ø³ÌµÄʱºò£¬Èç¹û´«µÝµÚ¶þ¸ö²ÎÊýΪ1
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //ÄÇô²Ù×÷ϵͳ²»»áÔÚÖÕÖ¹ºó×Ô¶¯»½ÐÑexplorer,Èç¹ûΪ0,»áÖØÐÂÆô¶¯
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //explorer
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ TerminateProcess(piExplor.hProcess,1);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ //¹Ø±ÕÐéÄâ×ÀÃæ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ CloseDesktop(hVirtualDesk);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ SendMessage(hwnd,WM_CLOSE,0,0);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ return 0;
¡¡¡¡¡¡¡¡ }
¡¡¡¡¡¡¡¡ return DefWindowProc (hwnd, message, wParam, lParam) ;
}
±¾ÆªÎÄÕÂÀ´Ô´ÓÚ£º¿ª·¢Ñ§Ôº http://edu. ÔÎÄÁ´½Ó£ºhttp://edu.