Page 1 of 1

How to check registry value data

Posted: Tue Dec 02, 2008 6:46 am
by alemrantareq
Hi everybody,
I've set a dword value into my registry -

Code: Select all

put "HKEY_CURRENT_USER\Software\MyKey\MyValueName" into theKey
get setRegistry(theKey, binaryEncode("I", 1), "dword")
Now I need to query the registry whether the value data of the value "MyValueName" is 0 or 1. I can query only the registry key and the value name using queryregistry function, but can't query the value data. How to query the value data?

It'd be better if anybody solve this using my example. Thanks in advance... :lol:

Posted: Tue Dec 02, 2008 9:34 am
by SparkOut
Edited below to correct error:

Code: Select all

put binaryDecode("I",queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName"),tTypeValue) into tValue
Assuming there is just one byte of data, tValue will hold the will then hold the bindaryDecoded result. tTypeValue will hold the key type information - in this case 1 as it is binary.

Posted: Tue Dec 02, 2008 11:31 am
by Mark
Dear alemrantareq,

Usually, the data in the registry isn't binary. In this case, it is probably just a 0 and a 1. This is also binary of course, but you don't need to decode it. Just check whether theKey = 0 or theKey = 1.

Kind regards,

Mark

Posted: Wed Dec 03, 2008 6:23 am
by alemrantareq
Hi SparkOut,
Thanks for your reply. It works good. It was for checking dword value. Now I need another little help to query the string value. Please, use my example with the string value "MyValueData". Thanks in advance...

Posted: Wed Dec 03, 2008 10:33 am
by SparkOut
Actually the original info above didn't work - it was returning 1 because that was the data type (ie binary) - and your example key had only binary value 1 stored, so the result was the same.

There is an optional type variable you can use in the queryRegistry function which will return the data type of the key. To actually obtain the value you can just put the queryRegistry result into a variable, as:

Code: Select all

put binaryDecode("I",queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName"),tTypeValue) into tValue
tValue will hold the binaryDecoded result, and tTypeValue will hold 1 (as the key holds binary data), or ignoring the type, just

Code: Select all

put binaryDecode("I",queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName")) into tValue
tValue will hold the binaryDecoded result. (You need to look up the binaryDecode function to make sure that you decode the right number of bytes).

If it is regular numeric data in the dword key, then

Code: Select all

put queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName"),tTypeValue) into tValue
tValue will hold the key data, and tTypeValue will hold "dword", again the type variable is optional:

Code: Select all

put queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName") into tValue
to return the key data into tValue.

String data is handled very simply:

Code: Select all

put queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName", tTypeValue) into tValue
tValue holding the key data string, and tTypeValue holding "string" - again tTypeValue is optional, so

Code: Select all

put queryRegistry("HKEY_CURRENT_USER\Software\MyKey\MyValueName") into tValue
will hold the key data string.