每当我使用MessageBox函数时,我都会遇到第一次例外情况。我的消息框是这样的。
MessageBox(NULL, (LPCWSTR)L"testing", (LPCWSTR)L"SOFTSAFETY", MB_OKCANCEL | MB_ICONWARNING);
如果我调试,我得到这个
First-chance exception at 0x76267A24 (user32.dll) in Thread Message BOX.exe: 0xC0000005: Access violation reading location 0x001629D0.
First-chance exception at 0x76267A24 (user32.dll) in Thread Message BOX.exe: 0xC0000005: Access violation reading location 0x001629D0.
First-chance exception at 0x76267A24 (user32.dll) in Thread Message BOX.exe: 0xC0000005: Access violation reading location 0x001629D0.
First-chance exception at 0x76267A24 (user32.dll) in Thread Message BOX.exe: 0xC0000005: Access violation reading location 0x001629D0.
如何删除这些例外?由于此异常,我的程序未挂起,它仅显示在输出窗口中。所以我可以忽略这些。请指导我。
也许看看MSDN会对您有所帮助?MessageBox函数具有以下原型:
int WINAPI MessageBox(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType
);
LPCTSTR
是指向的指针TCHAR
,并且不一定是宽字符。在中wtypes.h
,您将找到:
const TCHAR *LPCTSTR
并且TCHAR
可以wchar_t
或char
,这取决于项目的设置。几乎可以肯定,您的问题是您(通过强制转换)在期望使用常规字符的地方使用了宽字符。
您可以尝试使用_T()
宏,以根据项目的配置生成常规或宽字符串文字。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句