|
-
Apr 11th, 2007, 06:19 AM
#1
Thread Starter
Hyperactive Member
RegOpenKey not working
I always get this error:
RegOpenKeyEx failed with error code : 2
Please can some one explain why this is happening i am using an admin account
Code:
fResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
KeyName, 0, _
READ_CONTROL Or WRITE_DAC, hkey)
If fResult <> ERROR_SUCCESS Then
MsgBox "RegOpenKeyEx failed with error code : " & fResult
Else
UpdatePermissionsOfRegistryKey hkey, Accounts
RegCloseKey hkey
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Apr 11th, 2007, 07:01 AM
#2
Re: RegOpenKey not working
RegOpenKeyEx HKEY_CURRENT_USER, "YourSubkey", 0, KEY_ALL_ACCESS, Result
The Result and Hkey are reversed in your code.
It returns the Hkey and delivers a Result in an argument.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Apr 11th, 2007, 08:24 AM
#3
Thread Starter
Hyperactive Member
Re: RegOpenKey not working
thanks,
Does anybody know how to fix it, it sets permissions on the reg keys
If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.
If you fail, try and try again, its the only way to success.
-
Apr 11th, 2007, 01:30 PM
#4
Re: RegOpenKey not working
Did you reverse Result and Hkey in your code?
-
Apr 12th, 2007, 03:45 AM
#5
Re: RegOpenKey not working
@ chris1990. Your code is correct for what you are trying to achieve. The error code 2 is telling you (most likely) that the subkey doesn't exist. Do a Debug.Print on "KeyName" and check that it already exists in the registry to make sure it's valid.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|