Run-Time Check Failure #0 - 错误问题
很久沒寫代碼,一天幾行的代碼:
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 , 現在突然就需要了,很是迷惑??? 盼知情者指點!
總結
以上是生活随笔為你收集整理的Run-Time Check Failure #0 - 错误问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SwiftUI 日期大全之日期日历年月日
- 下一篇: 如何编辑教师岗位求职简历?优质的教师求职