Enumwindows(EnumwinowsProc,0);
BOOL CALLBACK EnumwindowsProc(HWND hwnd,LPARAM lParam);编译时ERROR:Enumwindows can't convert 1 paramer from "int [HWND hwnd,LPARAM lParam]"
to "int [__stdall] [HWND hwnd,LPARAM lParam]

解决方案 »

  1.   

    Enumwindows( &EnumwinowsProc, 0);
      

  2.   

    CALLBACK BOOL EnumwindowsProc(HWND hwnd,LPARAM lParam);
      

  3.   

    ::EnumWindows((WNDENUMPROC)(&EnumFunc),0);BOOL  EnumFunc(HWND hwnd,LPARAM lParam)
    {  return TRUE;
    }
      

  4.   

    static BOOL CALLBACK ListWindows(HWND hwnd,LPARAM lParam)
    {
        //...
        //...
    }//...
    EnumDesktopWindows(NULL, ListWindows, 0 /*(LPARAM)this*/);
      

  5.   

    回调函数必须是静态函数而不能是class的成员函数,下面的例子可以编译通过:
    BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
    {
    char windowsText[500];
    int nCount=::SendMessage(hwnd,WM_GETTEXTLENGTH,NULL,NULL);
    ::GetWindowText(hwnd,windowsText,nCount);
    // m_emnuwindow.AddString(windowsText);
    return true;
    }void CTestDlg::OnOK() 
    {
    // TODO: Add extra validation here
    EnumWindows(EnumWindowsProc,0);//
    CDialog::OnOK();
    }