Overkill Posted January 20, 2009 Share Posted January 20, 2009 (edited) Using AutoIt ver. 3.3.0.0$x = RegRead("HKEY_LOCAL_MACHINE","") $y = @error MsgBox(0,"Test",'Value: "'&$x&'"'&@CRLF&"@ERROR: "&$y)Returns "" and sets @ERROR to -1In regedit, (Default) = (value not set)I'm trying to use RegRead() to see if a specific key exists - there may/may not be a valuename to read. The program checks to see if a registry key entered by the user via command line or GUI exists and it is not logical, within the scope of this program, to define (Default).I can't use RegWrite() here because it will create the key if it doesn't already exist, which is not the goal.Ultimately, this program will be used to open the registry at a defined key using the method here:http://windowsitpro.com/article/articleid/...ecific-key.htmlexcept the code will actually work =) Edited January 20, 2009 by Overkill Link to comment Share on other sites More sharing options...
Manjish Posted January 20, 2009 Share Posted January 20, 2009 Using AutoIt ver. 3.3.0.0 $x = RegRead("HKEY_LOCAL_MACHINE","") $y = @error MsgBox(0,"Test",'Value: "'&$x&'"'&@CRLF&"@ERROR: "&$y) Returns "" and sets @ERROR to -1 In regedit, (Default) = (value not set) I'm trying to use RegRead() to see if a specific key exists - there may/may not be a valuename to read. The program checks to see if a registry key entered by the user via command line or GUI exists and it is not logical, within the scope of this program, to define (Default). I can't use RegWrite() here because it will create the key if it doesn't already exist, which is not the goal. Ultimately, this program will be used to open the registry at a defined key using the method here: http://windowsitpro.com/article/articleid/...ecific-key.html except the code will actually work =) Oh, I understand the problem here.. But i have a workaround to this 1.. It's a bit tedious, but it might work.. Y don't u generate a list of reg keys defined, by doing a RegEnum. Put this in a text file, and then search that text file for the key ur program wrote to the registry. [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
Overkill Posted January 20, 2009 Author Share Posted January 20, 2009 (edited) Oh, I understand the problem here..But i have a workaround to this 1..It's a bit tedious, but it might work..Y don't u generate a list of reg keys defined, by doing a RegEnum. Put this in a text file, and then search that text file for the key ur program wrote to the registry.My program only edits the registry value for the most recently used key, then opens the registry. At no point in time does this program actually create a new registry key.Step 1: User inputs registry key they want to open regedit toStep 2: Program checks to see if entered key is valid (it exists), continues to Step 3 if exists and gives error message otherwise.Stpe 3: Program modifies an existing registry entry (see reference in first post) in Windows to the value defined in Step 1Step 4: Opens the registryRegEnumKey/RegEnumVal will give an error if there isn't a value or subkey in the defined key, which is not what I want. Edited January 20, 2009 by Overkill Link to comment Share on other sites More sharing options...
Manjish Posted January 20, 2009 Share Posted January 20, 2009 OK.. fine.. The problem here is that autoit reads the keyname default as "". But if i und correctly, ur prob is that u can't diff between whether the key actually exists or whether its name and value are default. Am I right? [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
trancexx Posted January 20, 2009 Share Posted January 20, 2009 Using AutoIt ver. 3.3.0.0 $x = RegRead("HKEY_LOCAL_MACHINE","") $y = @error MsgBox(0,"Test",'Value: "'&$x&'"'&@CRLF&"@ERROR: "&$y) Returns "" and sets @ERROR to -1 In regedit, (Default) = (value not set) I'm trying to use RegRead() to see if a specific key exists - there may/may not be a valuename to read. The program checks to see if a registry key entered by the user via command line or GUI exists and it is not logical, within the scope of this program, to define (Default). I can't use RegWrite() here because it will create the key if it doesn't already exist, which is not the goal. Ultimately, this program will be used to open the registry at a defined key using the method here: http://windowsitpro.com/article/articleid/...ecific-key.html except the code will actually work =)Everything is ok here. (Default) REG_SZ (value not set) is the way regedit is interpreting nothing. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Overkill Posted January 20, 2009 Author Share Posted January 20, 2009 (edited) OK.. fine.. The problem here is that autoit reads the keyname default as "". But if i und correctly, ur prob is that u can't diff between whether the key actually exists or whether its name and value are default. Am I right?The problem is that I can't use the RegRead function to determine whether or not the key exists Everything is ok here. (Default) REG_SZ (value not set) is the way regedit is interpreting nothing.I'm aware of that, and the source of my issue is the AutoIt code, not the registry. $x = RegRead("HKEY_LOCAL_MACHINE") $y = RegRead("INVALID_KEY_NAME") MsgBox(0,"",StringCompare($x,$y)) ;0 Means values are the same It looks like I'm going to do some work with the @ERROR flag set by RegRead() instead of actually using the value it returns - something I wanted to avoid if possible. Edited January 20, 2009 by Overkill 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