#include
<
iostream.h
>
#include
<
string
.h
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
#include
<
windows.h
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
BOOL CALLBACK EnumFunc(HWND hwnd,LPARAM lParam);
BOOL CALLBACK EnumChildFunc(HWND hwnd,LPARAM lParam);
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
int
main(
int
argc,
char
*
argv[])
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
LPARAM lParam = 0;
EnumWindows(EnumFunc,lParam);
system("PAUSE");
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
#include
<
iostream.h
>
BOOL CALLBACK EnumFunc(HWND hwnd,LPARAM lParam)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
static int count = 0;
LPTSTR pszFileName = new char [100];
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
GetWindowText(hwnd,pszFileName,100);
cout<<"main hwnd"<<count++<<": "<<hwnd<<" "<<pszFileName<<endl
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
EnumChildWindows(hwnd,EnumChildFunc,lParam);
system("pause");
return true;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
BOOL CALLBACK EnumChildFunc(HWND hwnd,LPARAM lParam)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
static int count = 0;
LPTSTR pszFileName = (LPTSTR) new char [250];
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
GetWindowText(hwnd,pszFileName,250);
cout<<" child hwnd "<<hwnd<<count++<<": "<<pszFileName<<endl;
return true;
}
转载于:https://www.cnblogs.com/ubunoon/archive/2006/10/24/2058956.html