DW1 Posted September 11, 2008 Share Posted September 11, 2008 When you regread() a default value ( RegRead( <regkey>,"") ), but the default value has no value set (Appears in regedit as Name: "(Default)", Type: "REG_SZ", Data: "(value not set)" ), regread will error out. Is this expected behavior? It very well might be... just want to know Reproducer: Test 1 will pass because it has a value... Test 2 will fail because there is no value set: $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") If @error Then MsgBox(0, "Test 1", "Error reading registry: " & @error) Else MsgBox(4096, "Test 1", "passed") EndIf $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "") If @error Then MsgBox(0, "Test 2", "Error reading registry: " & @error) Else MsgBox(4096, "Test 2", "passed") EndIf AutoIt3 Online Help Link to comment Share on other sites More sharing options...
trancexx Posted September 11, 2008 Share Posted September 11, 2008 I don't get that error. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Author Share Posted September 11, 2008 (edited) I don't get that error.Really, both pass for you?.... man... WTF LOL EDIT: I was running 3.2.10.0 I will update to latest build and test again... Updated to latest build.... still fails for me on test2 fails on beta also. @trancexx: can you run this and have it pass? $var = RegRead("HKEY_LOCAL_MACHINE", "") If @error Then MsgBox(0, "Test 2", "Error reading registry: " & @error) Else MsgBox(4096, "Test 2", "passed") EndIf Edited September 11, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
trancexx Posted September 11, 2008 Share Posted September 11, 2008 @error = -1 just as for $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "Imaginarykey") ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Author Share Posted September 11, 2008 (edited) OK, so is this expected behavior? for a default key with no value... not an imaginary key that does not exist EDIT: Or is a default key with no value actually an imaginary key that only exists in the regedit gui? Edited September 11, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
trancexx Posted September 11, 2008 Share Posted September 11, 2008 OK, so is this expected behavior? for a default key with no value... not an imaginary key that does not existEDIT: Or is a default key with no value actually an imaginary key that only exists in the regedit gui?You could say that we are thinking along the same line about this. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Author Share Posted September 11, 2008 LOL, Can we get final word from a dev if this is expected behavior or not? It would be nice if a default key with no value still returned without an @error to use it as a sort of RegKeyExists function instead of having to use RegEnumKey in a loop at 1 key level higher. Maybe I just haven't seen the proper way to check if a key exists when it is empty (only has a default value in it with no data). Can somebody show me an example? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Skruge Posted September 11, 2008 Share Posted September 11, 2008 Maybe I just haven't seen the proper way to check if a key exists when it is empty (only has a default value in it with no data). Can somebody show me an example?RegRead("HKLM\Software\ImaginaryKey", "") If @error = 1 then ConsoleWrite("Key does not exist") The problem is, you're looking for a non-zero @error code rather than looking its value. From the RegRead help entry: Failure: Returns "" and sets the @error flag: 1 if unable to open requested key 2 if unable to open requested main key 3 if unable to remote connect to the registry -1 if unable to open requested value -2 if value type not supported Default values that appear in Regedit as "(value not set)" do not actually exist, so RegRead will set @error to -1. Default values can also be blank strings, in which case they do exist and RegRead will not error out. Try editing a Default value in Regedit to see the difference. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
DW1 Posted September 11, 2008 Author Share Posted September 11, 2008 The problem is, you're looking for a non-zero @error code rather than looking its value.Oh wow... is it Friday yet? LOLWell mark that down as one of my stupid user tricks Thanks AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now