大家帮忙看看这段代码哪里 错了?我得到的窗口句柄总是为0 !
ppyy 2001-12-20 04:55:16 HWND Had[3];
BOOL CALLBACK EnumWindowsProc(HWND hwnd, DWORD lParam)
{
char szCaption[127];
::GetWindowText(hwnd,szCaption,127);
for (int i=0;i<=3;i++);
{
if (!(strcmp(szCaption,"我的窗口")))
{
if (Had[i]==0)
Had[i]=hwnd;
}
}
return true;
}
void CFindwindowDlg::OnButton1()
{
// TODO: Add your control notification handler code here
for (int i=0;i<=3;i++)
{
Had[i]=0;
}
EnumWindows((int (__stdcall *)(struct HWND__ *,long))EnumWindowsProc, 0);
CString szStr;
szStr.Format("%d",Had[0]);
::MessageBox(NULL,szStr,"test",MB_ICONINFORMATION);
}
我桌面上有四个窗口的标题都是“我的窗口”,但是程序运行的时候弹出的对话框总是0