How to check registry value data

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

How to check registry value data

Post by alemrantareq » Tue Dec 02, 2008 6:46 am

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:

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Dec 02, 2008 9:34 am

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.
Last edited by SparkOut on Wed Dec 03, 2008 10:17 am, edited 1 time in total.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Dec 02, 2008 11:31 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Wed Dec 03, 2008 6:23 am

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...

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Dec 03, 2008 10:33 am

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.

Post Reply