setRegistry on Windows 64-bit

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

setRegistry on Windows 64-bit

Post by Ledigimate » Fri Apr 11, 2014 1:03 pm

Hi

I'm using LiveCode on Windows 8 (64-bit) and trying to change registry entries which are also accessed by some other non-LiveCode applications, located under
"HKEY_LOCAL_MACHINE\Software\myCompany\"
but the values I set with the setRegistry function are only visible to LiveCode and not to any other non-LiveCode applications.

I know that the "HKEY_LOCAL_MACHINE\Software\Wow6432Node\" key contains registry entries for 32-bit applications, but not even 32-bit applications can see the changes made by my LiveCode application.
It's giving me a headache. It's like my LiveCode app sees a seperate version of the "HKEY_LOCAL_MACHINE\Software\" key. How can LiveCode have its own seperate version of "HKEY_LOCAL_MACHINE\Software\" ?????

Can someone else please test this on your 64-bit Windows machine and post what you find?

Thanks in advance 8)
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

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

Re: setRegistry on Windows 64-bit

Post by Mark » Fri Apr 11, 2014 2:08 pm

Hi,

To make this work, you probably need to start your app as administrator.

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

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: setRegistry on Windows 64-bit

Post by Ledigimate » Fri Apr 11, 2014 5:19 pm

Thank you, Mark! That resolved the issue. Windows 8 must have sandboxed LiveCode by default.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: setRegistry on Windows 64-bit

Post by Ledigimate » Fri Apr 11, 2014 5:39 pm

Now, I have another issue with setRegistry:

I need to be able to change an entry only if its key already exists. How can I prevent the key from being created when it doesn't exist? The queryRegistry isn't of much help here because it returns empty for keys that doesn't exist. It also returns empty if the key exists and the default value is not set. I need to be able to detect if the key exists before attempting to change the entries it contains.

Please advise?
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

Re: setRegistry on Windows 64-bit

Post by Ledigimate » Tue Apr 15, 2014 3:55 pm

Hello fellow LoveCoders,

After a long search, I came to the conclusion that I will have to create a LiveCode external with a function that can probe for the existence of a value in the Windows 32-bit registry. And so I did!

I wrote a "regValueExists" function that takes 3 arguments: pRootKeyName, pSubKeyPath, pValueName
and returns true if the value exists in the registry, or false if it doesn't exist.

I've attached the external to this post. To use it in LiveCode, do the following:
  • Extract the Zip-archive and copy "windowsregistry.dll" to the following 2 folders on your computer:
    <User Extensions>/Externals
    <User Extensions>/Runtime/Windows/x86-32/Externals
    where <Users Extensions> is the location specified in "Edit > Preferences > Files & Memory > User Extensions". If one or both of the "Externals" folders above don't exist then you should create them first.
  • Edit the "Externals.txt" file in each of the "Externals" folders above, adding the following line:
    windowsregistry external,windowsregistry.dll
    If the "Externals.txt" file does not exist in one or both of the "Externals" folders, then you should create it.
  • Restart LiveCode.
Remember to also add a reference to this external in the properties of each stack that utilise it, or else it won't work in a standalone, e.g. Externals\windowsregistry.dll

After the above steps, you can call the "regValueExists" function to probe for the existence of a specified value in the Windows 32-bit registry, as in the following example:

Code: Select all

put regValueExists("HKEY_CURRENT_USER", "SOFTWARE\myCompany", "myValue") into tValueExists
For some reason it works as part of a script, but not in the message box. Nevertheless, it works :D .

I hope someone else finds this useful. I needed it because I needed to probe for the existence of the registry value before changing it with the setRegistry function.

Kind regards,

Gerrie
Attachments
windowsregistry.zip
windowsregistry external
(20.82 KiB) Downloaded 252 times
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Post Reply

Return to “Windows”