我遇到内存访问冲突,我无法弄清楚。
这是我的代码
// Called by EnumWindows function.
BOOL CALLBACK EnumWindowsProc(
HWND hwnd,
LPARAM lParam
)
{
TCHAR buf[1024];
WINDOWINFO pwi;
WNDCLASSEX wcex;
GetWindowText(hwnd, buf, 1024);
GetWindowInfo(hwnd, &pwi);
if (GetClassInfoEx(NULL, MAKEINTATOM(pwi.atomWindowType), &wcex)) {
// ************** read AccessViolation wcex.lpszClassName **************
wsprintf(catbuf, _T("className=%s, top=%d, left=%d, right=%d, bottom=%d\r\n"), wcex.lpszClassName, pwi.rcWindow.top, pwi.rcWindow.left, pwi.rcWindow.right, pwi.rcWindow.bottom);
OutputDebugString(catbuf);
}
return TRUE;
什么可能导致访问冲突?