Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error using RegCreateKeyEx()

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to create a key using the API - RegCreateKeyEx.
I keep getting baffled by a run time error - "Unhandled exception in project.exe (ADVAPI32.DLL): 0xC0000005: Access Violation."

I am running this under windows XP pro and I AM the administrator.

Here's my code:

PHKEY phkResult1=NULL;
LPDWORD lpdwDisposition1;
DWORD dwOptions = REG_OPTION_NON_VOLATILE;
long lRes =0;

lRes = RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\myproject",0, "", dwOptions, KEY_CREATE_SUB_KEY, NULL, phkResult1,lpdwDisposition1);

Any help or suggestion ....... Thank you.
 
You're passing in non-allocated pointers.

Change your code to:

HKEY phkResult1=NULL;
DWORD lpdwDisposition1;
DWORD dwOptions = REG_OPTION_NON_VOLATILE;
long lRes =0;

lRes = RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\myproject",0, "", dwOptions, KEY_CREATE_SUB_KEY, NULL, &phkResult1,&lpdwDisposition1);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top