Jump to content

Checking for (Default) with RegRead


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :(
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...