setRegistry and queryRegistry not working with "\"

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ocean
Posts: 16
Joined: Wed May 03, 2006 4:29 am

setRegistry and queryRegistry not working with "\"

Post by Ocean » Sat Feb 23, 2008 8:47 am

It appears that setRegistry and getRegistry do not work at all if the character "\" is present in the name of the value.

For instance, I am trying to set the following registry key, but am unable to do so via Revolution:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
Name: C:\Path\To\My\App.exe
Type: REG_SZ
Data: WIN98

1. What is the correct setRegistry command to do this?

The following command does not work (Revolution thinks the "\" in the application path belongs to the registry path rather than to the value name):

Code: Select all

setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\C:\Path\To\My\App.exe","WIN98")
This doesn't work either (attempting to use an additional "\" to "escape" the original "\"):

Code: Select all

setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\C:\\Path\\To\\My\\App.exe","WIN98")
2. What is the correct getRegistry command to verify the current setting of the above data?

The following command does not work:

Code: Select all

getRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\C:\Path\To\My\App.exe")
Thanks in advance.

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

Post by Mark » Sat Feb 23, 2008 10:19 am

Hi Ocean,

This might help (I know it works):

http://article.gmane.org/gmane.comp.ide ... +name+path

Best,

Mark
Last edited by Mark on Sat Feb 23, 2008 11:03 pm, edited 1 time in total.
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

Ocean
Posts: 16
Joined: Wed May 03, 2006 4:29 am

Post by Ocean » Sat Feb 23, 2008 10:41 am

Thanks for the link. Unfortunately, in that article the "\" is in the data of the value rather than in the name of the value (which is what we need). :?

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

Post by Mark » Sat Feb 23, 2008 11:52 am

Hi Ocean,

If you read the post I linked to, you'll see that

1) you need to define a name
2) an application path to that name
and now you also want to
3) define a compatibility flag for that name

Best,

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

Ocean
Posts: 16
Joined: Wed May 03, 2006 4:29 am

Post by Ocean » Sat Feb 23, 2008 9:23 pm

Hey Mark, :)

I've taken a look at the article again and can confirm that it does not contain the solution (the path to the app is definitely in the data of the value rather than in the name of the value).

It appears no one has actually needed to put the path of an app in the name of a value using Revolution prior to this, and so this is the first time this error (possibly a Revolution bug) is being encountered.

In the meantime, we've implemented a workaround (using reg.exe to manipulate the registry via the command line instead).

Thanks anyway! :)

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

Post by Mark » Sat Feb 23, 2008 10:06 pm

Ocean,

There is a reason why nobody ever need to enter a path! As I wrote, you must define compatibility flags for the NAME and not for the PATH.

Best,

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

Ocean
Posts: 16
Joined: Wed May 03, 2006 4:29 am

Post by Ocean » Sat Feb 23, 2008 10:48 pm

Could you provide some examples of what you mean by "compatibility flags for the NAME and not for the PATH"? Thanks! :)

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

Post by Mark » Sun Feb 24, 2008 12:36 am

Ocean,

After following all instructions given under aforementioned link, you should be able to execute code similar to

Code: Select all

setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\TestApp","WIN98")
Looking in the registry on my PC, I don't see this path (I mean the path to the registry key, not the path to the application). Are you sure the path is correct?

Best,

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

Ocean
Posts: 16
Joined: Wed May 03, 2006 4:29 am

Post by Ocean » Sun Feb 24, 2008 4:26 am

Mark wrote:Ocean,

After following all instructions given under aforementioned link, you should be able to execute code similar to

Code: Select all

setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\TestApp","WIN98")
Looking in the registry on my PC, I don't see this path (I mean the path to the registry key, not the path to the application). Are you sure the path is correct?

Best,

Mark
Aye. Normally that registry path only shows up if you have at least one program to which you have set special compatibility settings (at the Properties window).

Just right-click any exe on your drive, click Properties, then Compatibility, then select "Windows 98" or any other option from the menu, and save. Close and re-open RegEdit and you'll see the registry path show up. :)

You'll then also see what I mean by the program path being in the name of the value, rather than in the data of the value (which is "WIN98").

Post Reply

Return to “Talking LiveCode”