Sign in to follow this  
Followers 0
Overkill

RegRead Function

6 posts in this topic

#1 ·  Posted (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 -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 =)

Edited by Overkill

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 to

Step 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 1

Step 4: Opens the registry

RegEnumKey/RegEnumVal will give an error if there isn't a value or subkey in the defined key, which is not what I want.

Edited by Overkill

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by Overkill

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  
Followers 0