Run-Time Check Failure #0 - 错误问题

来源:互联网 发布:mac virtualbox传文件 编辑:程序博客网 时间:2024/05/02 02:03

很久没写代码,一天几行的代码:

typedef  int ( *PFUN)(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
void CTestProcessMonitorDlg::OnBnClickedButton1()
{
    // TODO: Add your control notification handler code here

    //MessageBox(TEXT("Hello"), TEXT("Test"));

    //typedef void (*pfv) ();

    HMODULE hmod = ::LoadLibraryExW(TEXT("user32.dll"), NULL, 0);
    if (hmod != NULL)
    {
        PFUN pFun= (PFUN)GetProcAddress(hmod, "MessageBoxW");
        if (pFun != NULL)
        {
            pFun(m_hWnd, TEXT("Hello"), TEXT("Test"), MB_YESNO);
        }

       :FreeLibrary(hmod);
    }

  
                 
}

突然出现以下的错误:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.



代码改为如下, 则问题没有了

typedef  int (WINAPI *PFUN)(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
void CTestProcessMonitorDlg::OnBnClickedButton1()
{
    // TODO: Add your control notification handler code here

    //MessageBox(TEXT("Hello"), TEXT("Test"));

    //typedef void (*pfv) ();

    HMODULE hmod = ::LoadLibraryExW(TEXT("user32.dll"), NULL, 0);
    if (hmod != NULL)
    {
        PFUN pFun= (PFUN)GetProcAddress(hmod, "MessageBoxW");
        if (pFun != NULL)
        {
            pFun(m_hWnd, TEXT("Hello"), TEXT("Test"), MB_YESNO);
        }

         ::FreeLibrary(hmod);
    }
                      
}

// 调用约定出现问题,以前这样调用api也没有用上WINAPI , 现在突然就需要了,很是迷惑??? 盼知情者指点!