使用WndClass读取位置时发生访问冲突

Access violation reading location using WndClass

本文关键字:访问冲突 位置 WndClass 读取 使用      更新时间:2023-10-16

我有一个问题,使用以下代码:

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