كود
// Compiled by Visual C++6.0 & C++ builder5.0 on winxp
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
HWND whandle[256];
int count=0;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
int main(int argc, char* argv[])
{
printf("Hide ? ");
int lParam=getchar();
if (lParam=='Y'||lParam=='y')
lParam=1; //enumerate & hide
else
lParam=0; //enumerate with hidding
getchar(); // Why ? You try to find the reason
EnumWindows(&EnumWindowsProc,lParam); //Hide
if(lParam==1) //Unhide
{
printf("Press anykey to unhide ...n");
getch();
for(int i=0;i<=count;i++)
ShowWindow(whandle[i],SW_SHOWNA);
}
printf("Press any key to halt ...n");
getch();
return 0;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char Buffer[256];
if( IsWindowVisible(hwnd) /*|| IsIconic(hwnd)*/)
//You try to keep the condition IsIconic & check the different
{
if(lParam==1)
{
whandle[count]=hwnd;
count++;
GetClassName(hwnd,Buffer,256);
if(
//Desktop
strcmp(Buffer,"Progman")&
//Our program
(hwnd!=GetForegroundWindow()) &
//TaskBar
strcmp(Buffer,"Shell_TrayWnd")
)
ShowWindow(hwnd,SW_HIDE);
}
//------- Show handle & Caption of windows---
GetWindowText(hwnd, Buffer, 256);
if(strlen(Buffer)== 0 )
strcat(Buffer , "Empty");
printf("%dt%sn",hwnd,Buffer);
//-------------------------------------------
}
return true;
}
هذا كود كتبه يوما اخي tmaaa , ترى كيف يقوم البرنامج برصد كل النوافذ الموجودة (الشغالة), وانت تضع الشرط للنافذة التي تريدها...
جرب الكود واي مشكلة إسأل.