#include <windows.h>
int main()
{
HKEY hKey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\HATEREG\\", 0,
KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
RegCloseKey(hKey);
DWORD ub;
RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\HATEREG\\",
0,TEXT(""),REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
NULL,&hKey,&ub);
return 0;
}
This code crash the computer on windows XP:
Why?
Thanks.
not to be unhelpful or anything, but if you wrote it, shouldn''t you know why? Or are you just copying other peoples code?
I have written this code. It works on my computer (win2000)
but not on a friends computer (winXP).
but not on a friends computer (winXP).
Nothing, just a test! Try to open a key "named "SOFTWARE\\HATEREG\\" in HKEY_LOCAL_MACHINE, then close that key and create it again.
what line does it crash on.
Why do you need to call RegCloseKey if the key failed to be opened, I would assume that no memory was allocated for the hkey variable so closing it should be unnecessary. I could be wrong though, I don''t know anything about these registry functions.
Why do you need to call RegCloseKey if the key failed to be opened, I would assume that no memory was allocated for the hkey variable so closing it should be unnecessary. I could be wrong though, I don''t know anything about these registry functions.
Like I said. It''s only a example ripped from another project! What I don''t get is why this CRASH the os. Can this happen?
My friend have only executed the exe file, he have not access to the code so he can not track the error to a line.
Thanks.
My friend have only executed the exe file, he have not access to the code so he can not track the error to a line.
Thanks.
try creating the key manually first and then run the program again. If is doesn''t crash then the call to RegCloseKey is causing the crash since the variable hKey is NULL.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement