Help! Access violation error in C++
Hi everyone! I'm trying to enumerate registry keys:
Code:
LONG i;
HKEY root;
DWORD retCode;
DWORD dwIndex=0;
CHAR achKey[MAX_PATH];
const TCHAR szRegRoot[] = _T("Software\\Microsoft\\Office");
retCode=RegOpenKeyEx(HKEY_CURRENT_USER, szRegRoot, 0, KEY_READ, &root);
for (i = 0, retCode = ERROR_SUCCESS; retCode == ERROR_SUCCESS; i++)
{ retCode = RegEnumKeyEx(root,
i,
achKey,
(ULONG *)MAX_PATH,
NULL,
NULL,
NULL,
NULL);
}
When I about to execute RegEnumKeyEx(...) I got the error:
First-chance exception in p5.exe (ADVAPI32.DLL): 0xC0000005: Access Violation.:confused:
Enviroment: Win2K, VC++6.0.
Thanks!