必须把FARPROC proc改成
(WINAPI *)proc(CONST WNDCLASSEXA *);
以及
#if defined (UNICODE)
      proc = GetProcAddress (hMod, "RegisterClassExW");
#else
      proc = GetProcAddress (hMod, "RegisterClassExA");
#endif加上((WINAPI *)(CONST WNDCLASSEXA *))GetProcAddress (hMod, "RegisterClassExW");
因为FARPROC是一个无参数的定义类型,如果要动态调用函数,必须定义其参数类型

解决方案 »

  1.   

    不行,这句(WINAPI *)proc(CONST WNDCLASSEXA *);一写就报错。
      

  2.   

    SORRY,刚才搞错了,我试了一下,如下修改就可以了:
    typedef ATOM(* PROC1) (CONST WNDCLASSEX *lpwcx); 
    #define PROC_FUNCTION "RegisterClassEx"ATOM CRegDlg::MyRegisterClass(CONST WNDCLASS *lpwc)
    {
      HANDLE  hMod;
      PROC1 proc;
      WNDCLASSEX wcex;  hMod = GetModuleHandle ("USER32");
      if (hMod != NULL) {#if defined (UNICODE)
          proc = (PROC1)GetProcAddress (hMod, "RegisterClassExW");
    #else
      proc = (PROC1)GetProcAddress ((HINSTANCE)hMod, "RegisterClassExA");
    #endif      if (proc != NULL) {        wcex.style        = lpwc->style;
            wcex.lpfnWndProc  = lpwc->lpfnWndProc;
            wcex.cbClsExtra    = lpwc->cbClsExtra;
            wcex.cbWndExtra    = lpwc->cbWndExtra;
            wcex.hInstance    = lpwc->hInstance;
            wcex.hIcon        = lpwc->hIcon;
            wcex.hCursor      = lpwc->hCursor;
            wcex.hbrBackground = lpwc->hbrBackground;
            wcex.lpszMenuName  = lpwc->lpszMenuName;
            wcex.lpszClassName = lpwc->lpszClassName;        // Added elements for Windows 95:
            wcex.cbSize = sizeof(WNDCLASSEX);
            wcex.hIconSm = LoadIcon(wcex.hInstance, "SMALL");        return (*proc)(&wcex);//return RegisterClassEx(&wcex);
          }
      }
      return (RegisterClass(lpwc));
    }
      

  3.   

    补充一下:
    #define PROC_FUNCTION "RegisterClassEx" //不要
    改正:
    #if defined (UNICODE)
          proc = (PROC1)GetProcAddress ((HINSTANCE)hMod, "RegisterClassExW");
    #else
          proc = (PROC1)GetProcAddress ((HINSTANCE)hMod, "RegisterClassExA");
    #endif