Jump to content
Sign in to follow this  
Adam9

Checking for (Default) with RegRead

Recommended Posts

Adam9

For some reason, I can't get @error to return 0 when I do RegRead('RegKey', ''). The key definitely exists, and the documentation/forum says to use '' for (Default). I simply want to check for the existence of a key that contains other keys, for example, CurrentVersion. If I specify a value that exists, @error will return 0 (which is good), but '' always returns -1 even if the key exists.

Any ideas on why this won't work for me? Thanks.

Share this post


Link to post
Share on other sites
Adam9

Thanks for the quick reply! It works beautifully.

Share this post


Link to post
Share on other sites
Adam9

Well, some of the registry keys I'm checking for do not have subkeys. So unfortunately, I can't use RegEnumKey. I've tried the beta AutoIt, current, and 3.1.0, and they always give me an @error of not 0 regardless of whether the key exists or not.

$check = RegRead($regkey, "")

$regkey being the path to the key.

Thanks in advance for any help.

Share this post


Link to post
Share on other sites
jpm

I cannot reproduce your problem :(

the following code work as design

$regkey="HKCR\.2bp"
$check = RegRead($regkey, "")   
MsgBox(262144,'Debug line ~13','Selection:' & @lf & '$check' & @lf & @lf & 'Return:' & @lf & $check & @lf & @lf & '@Error:' & @lf & @Error & @lf & @lf & '@Extended:' & @lf & @Extended);### Debug MSGBOX
$regkey="HKCR\.2bp1"
$check = RegRead($regkey, "")   
MsgBox(262144,'Debug line ~13','Selection:' & @lf & '$check' & @lf & @lf & 'Return:' & @lf & $check & @lf & @lf & '@Error:' & @lf & @Error & @lf & @lf & '@Extended:' & @lf & @Extended);### Debug MSGBOX

Share this post


Link to post
Share on other sites
Adam9

That code also works for me, but the keys you used have default values in them. I just need to check if the key exists because most keys do not have default values.

Share this post


Link to post
Share on other sites
Adam9

I'm now having it check the registry using RegEnumVal and RegEnumKey. This combination works great. Thanks for all the help :(

Share this post


Link to post
Share on other sites
jpm

I'm now having it check the registry using RegEnumVal and RegEnumKey. This combination works great. Thanks for all the help :(

<{POST_SNAPBACK}>

I recheck you get 2 different @error -1 if the default is not set and 1 if the key is not defined as stated in the doc :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×