//使用软件为C++builder
GW_CHILD GW_HWNDNEXT
//int HandCount 定义的全局变量
//HWND Handled[1024] //定义的全局变量
//DebugInfo(AnsiString str) //自定义的字符串显示函数
//递归函数
void __fastcall TForm1::Gethh(HWND hendle)
{
HWND Group[1024];
HWND hh = GetWindow(hendle,GW_CHILD);
int count = 0;
if(hh != NULL)
{
int i=0;
Group[i] = hh;
do
{
Handled[HandCount++] = Group[i];
Group[i+1] = GetWindow(Group[i],GW_HWNDNEXT);
DebugInfo("Group["+AnsiString(i)+"] Hendle is 0x"+IntToHex((__int32)Group[i],8));
count = i+1;
}while(i++,NULL != Group[i]);
}
else 为了区别分支点,用以下隔开
{
Handled[HandCount++] = NULL; //为了区别分支点,用NULL隔开
DebugInfo("");
}
for(int j=0;j
Lines->Add("Handled["+AnsiString(i)+"] is 0x"+IntToHex((__int32)Handled[i],8));
}
}
//---------------------------------------------------------------------------
GW_CHILD GW_HWNDNEXT
//int HandCount 定义的全局变量
//HWND Handled[1024] //定义的全局变量
//DebugInfo(AnsiString str) //自定义的字符串显示函数
//int HandCount 定义的全局变量
//HWND Handled[1024] //定义的全局变量
//DebugInfo(AnsiString str) //自定义的字符串显示函数
//递归函数
void __fastcall TForm1::Gethh(HWND hendle)
{
HWND Group[1024];
HWND hh = GetWindow(hendle,GW_CHILD);
int count = 0;
if(hh != NULL)
{
int i=0;
Group[i] = hh;
do
{
Handled[HandCount++] = Group[i];
Group[i+1] = GetWindow(Group[i],GW_HWNDNEXT);
DebugInfo("Group["+AnsiString(i)+"] Hendle is 0x"+IntToHex((__int32)Group[i],8));
count = i+1;
}while(i++,NULL != Group[i]);
}
else 为了区别分支点,用以下隔开
{
Handled[HandCount++] = NULL; //为了区别分支点,用NULL隔开
DebugInfo("");
}
for(int j=0;j<count;j++)
{
Gethh(Group[j]);
}
}
void __fastcall TForm1::Gethh(HWND hendle)
{
HWND Group[1024];
HWND hh = GetWindow(hendle,GW_CHILD);
int count = 0;
if(hh != NULL)
{
int i=0;
Group[i] = hh;
do
{
Handled[HandCount++] = Group[i];
Group[i+1] = GetWindow(Group[i],GW_HWNDNEXT);
DebugInfo("Group["+AnsiString(i)+"] Hendle is 0x"+IntToHex((__int32)Group[i],8));
count = i+1;
}while(i++,NULL != Group[i]);
}
else 为了区别分支点,用以下隔开
{
Handled[HandCount++] = NULL; //为了区别分支点,用NULL隔开
DebugInfo("");
}
for(int j=0;j<count;j++)
{
Gethh(Group[j]);
}
}
void __fastcall TForm1::Button6Click(TObject *Sender) //举例
{
HandCount=0; //初始化全局变量
//HWND hh1 = FindWindowA("#32769 (??)",NULL); //"Cypress USB Console");
HWND hh1 = FindWindowA(NULL,"Cypress USB Console"); //获取一个窗口句柄
Gethh(hh1); //调用递归函数得到所有句柄
for(int i=0;i<HandCount;i++)
{
Report->Lines->Add("Handled["+AnsiString(i)+"] is 0x"+IntToHex((__int32)Handled[i],8));
}
}
//---------------------------------------------------------------------------
{
HandCount=0; //初始化全局变量
//HWND hh1 = FindWindowA("#32769 (??)",NULL); //"Cypress USB Console");
HWND hh1 = FindWindowA(NULL,"Cypress USB Console"); //获取一个窗口句柄
Gethh(hh1); //调用递归函数得到所有句柄
for(int i=0;i<HandCount;i++)
{
Report->Lines->Add("Handled["+AnsiString(i)+"] is 0x"+IntToHex((__int32)Handled[i],8));
}
}
//---------------------------------------------------------------------------