我有一个问题,使用这段代码:
BOOL RegisterApp(HINSTANCE hInst)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszClassName = szClassName;
//
//
return RegisterClass(&wc);
}
当我尝试使用 &wc
时,出现以下错误:
Unhandled exception at 0x763adf81 in lab3.exe: 0xC0000005: Access violation reading location 0xcccccccc.
请帮帮我,我需要用这个做什么?
最佳答案
你还没有初始化wc的所有数据成员。
引用http://msdn.microsoft.com/en-us/library/windows/desktop/ms633576(v=vs.85).aspx
关于c++ - 使用 WndClass 访问违规读取位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23202378/