C++ appcrash USER32.dll
C++ appcrash USER32.dll
Problem Event Name: APPCRASH
Application Name: program.exe
Application Version: 0.0.0.0
Application Timestamp: 537374b6
Fault Module Name: USER32.dll
Fault Module Version: 6.3.9600.16384
Fault Module Timestamp: 52157ca5
Exception Code: c0000005
Exception Offset: 0000949d
OS Version: 6.3.9600.2.0.0.256.48
Locale ID: 1049
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: 3a20
Additional Information 4: 3a20a93c34687143a5bf7d33f1cf3ccc
我试图使c++ winapi程序,其唯一的功能是绘制一个窗口的按钮,切换光标移动和点击,但在窗口显示后,应用程序崩溃之前能够做一些事情。在窗口过程中,我只有WM_COMMAND, WM_DESTROY和默认返回DefWindowProc()的情况。WinMain函数代码:
WNDCLASSEX wcx;
int X, Y;
MSG msg;
RECT srect;
GetWindowRect(GetDesktopWindow(), &srect);
X = srect.right;
Y = srect.bottom;
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW | CS_VREDRAW | CS_DROPSHADOW;
wcx.lpfnWndProc = MainProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hinst;
wcx.hIcon = 0;
wcx.hCursor = 0;
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.lpszMenuName = 0;
wcx.lpszClassName = L"wcname";
wcx.hIconSm = 0;
if (!RegisterClassEx(&wcx)){
MessageBox(0, L".", L"RegisterClass failed", 0);
return 1;
}
hwnd = CreateWindowEx(
0,
L"wcname",
L"off",
WS_OVERLAPPEDWINDOW,
X / 2 - 112,
Y / 2 - 40,
224,
80,
0,
0,
hinst,
0
);
if (!hwnd){
MessageBox(0, L".", L"CreateWindow failed", 0);
return 1;
}
GetClientRect(hwnd, &srect);
X = srect.right;
Y = srect.bottom;
btn = CreateWindowEx(
0,
L"button",
L"Turn on",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
0, 0,
X, Y,
hwnd,
(HMENU)BTN,
hinst,
0
);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(0, hwnd, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
hwnd为全局变量,BTN和MAIN为宏。
GetMessage的lpMsg
参数不允许为NULL(0)。
这叫:
while (GetMessage(0, hwnd, 0, 0))
必须是:
while (GetMessage(&msg, hwnd, 0, 0))
相关文章:
- 挂起和取消挂起一个文件DLL
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 导入库可以跨dll版本工作吗
- 从C++dll访问C#中的一行主要参数
- 链接到自行创建的dll失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- C++:将外部库链接到dll库
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 不同的Visual Studio版本中缺少.dll
- 从DLL中删除类的实例
- 如何包装第三方DLL在R中使用
- 使用c#访问c++dll中带有char*参数的函数时发生AccessViolationException
- 系统.将数组移交给c#中动态加载的c++DLL时发生AccessViolationException
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- LoadLibrary('user32.dll') 返回 14007
- 为什么我们需要链接kernel32.dll, user32.dll等.在Windows c++中
- C++ appcrash USER32.dll