问候一切,
在我的应用程序中,我使用下面的代码:
bool HandleMessages() { MSG msg; if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) return FALSE; TranslateMessage(&msg); DispatchMessage(&msg); } return true; }
这是Windows中消息处理的标准代码,我想,但是现在当我尝试运行程序时,我总是在PeekMessage()调用中得到一个Exception。
exception消息是
testing.exe中的0x57a10eed(msvcr100d.dll)未处理的exception:0xC0000005:读取位置0x6666665c时访问冲突。
我完全失去了这里,不知道为什么它会抛出一个例外。 任何人都有提示?
调用堆栈:
msvcr100d.dll!__ local_unwind2()+ 0x48 Bytes Asm
msvcr100d.dll!_except_handler3()+ 0xed Bytes Asm
Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord,_EXCEPTION_REGISTRATION_RECORD * EstablisherFrame,_CONTEXT * ContextRecord,void * DispatcherContext)+ 0x24字节C
Testing.exe!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord,_EXCEPTION_REGISTRATION_RECORD * EstablisherFrame,_CONTEXT * ContextRecord,void * DispatcherContext)+ 0x24字节C
拆卸:
继续 :
57CE0EEA lea esi,[esi + esi * 2]
57CE0EED mov ecx,dword ptr [ebx + esi * 4]
57CE0EF0 mov dword ptr [esp + 0Ch],ecx
57CE0EF4 mov dword ptr [eax + 0Ch],ecx
57CE0EF7 cmp dword ptr [ebx + esi * 4 + 4],0
57CE0EFC jne _lu_continue(57CE0F15h)
57CE0EFE推101h
57CE0F03 mov eax,dword ptr [ebx + esi * 4 + 8]
57CE0F07调用_NLG_Notify(57CE0F55h)
57CE0F0C mov eax,dword ptr [ebx + esi * 4 + 8]
57CE0F10调用_NLG_Call(57CE0F74h)
这是发生在第一次调用? 试试/抓住它有帮助吗? 另外,如果没有特定的原因使用PeekMessage(),为什么不使用GetMessage()呢?
msvcr100d.dll
崩溃,那么它发生在PeekMessage
之外(在调用之前或之后)。 你应该有很好的调试信息。 this
指针如果适用 我不认为你所发布的这个堆栈足以让任何事情都做出来。
有没有机会可以调用HandleMessages()来回应消息? 这可能会导致递归/堆栈耗尽。