1 #include<windows.h> 2 #include<stdio.h> 3 int main() 4 { 5 HWND hWnd; 6 /* 7 if(((hWnd = FindWindowEx(NULL, NULL, "Progman", NULL)) == NULL) ||((hWnd = FindWindowEx(hWnd, NULL, "SHELLDLL_DefView", NULL)) == NULL) ||((hWnd = FindWindowEx(hWnd, NULL, "SysListView32", NULL)) == NULL)) 8 { 9 printf("获取桌面窗口失败!\n"); 10 } 11 */ 12 while(1) 13 { 14 hWnd = FindWindowEx(NULL, NULL, "Progman", NULL); 15 if(hWnd == NULL) 16 { 17 printf("未找到Progman!\n"); 18 system("pause"); 19 } 20 hWnd = FindWindowEx(hWnd, NULL, "SHELLDLL_DefView", NULL); 21 if(hWnd == NULL) 22 { 23 printf("未找到SHELLDLL_DefView!\n"); 24 25 } 26 hWnd = FindWindowEx(hWnd, NULL, "SysListView32", NULL); 27 if(hWnd == NULL) 28 { 29 printf("未找到SysListView32!\n"); 30 } 31 else 32 ShowWindow(hWnd,SW_HIDE); 33 Sleep(1000); 34 } 35 return 0; 36 }
使用后,桌面会隐藏,任务栏不会隐藏,解决方法:
ShowWindow(hWnd,SW_SHOWNORMAL);
C-Free 5.0 windows XP下测试通过。