setRegistry - DWORD

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
glenn52
Posts: 25
Joined: Mon May 02, 2011 1:34 pm
Contact:

setRegistry - DWORD

Post by glenn52 » Sun Mar 31, 2013 6:17 am

Using this code I make the change to the Registry, however the value generates "invalid DWORD" error

Code: Select all

put "2" into tValue
get setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", tValue, "dword")
Anyone help getting "tValue" in the right format?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: setRegistry - DWORD

Post by Simon » Sun Mar 31, 2013 8:11 am

ooops?
get... err don't need that.
setRegistry kinda sounds like English.


Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

glenn52
Posts: 25
Joined: Mon May 02, 2011 1:34 pm
Contact:

Re: setRegistry - DWORD

Post by glenn52 » Sun Mar 31, 2013 8:51 am

Simon wrote:ooops?
get... err don't need that.
setRegistry kinda sounds like English.
Simon
:? errr.. what?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: setRegistry - DWORD

Post by Simon » Sun Mar 31, 2013 9:02 am

You shouldn't have "get" there...
get... like "get" your shoes. That is not what you are asking for, you what to change something, ..set your shoes on the floor. setRegistry.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

glenn52
Posts: 25
Joined: Mon May 02, 2011 1:34 pm
Contact:

Re: setRegistry - DWORD

Post by glenn52 » Sun Mar 31, 2013 9:07 am

Without the get, the set generates a Livecode "can't find handler" error.
With the get, I get a change in the registry value, however it is reported as invalid.
:wink:

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: setRegistry - DWORD

Post by Simon » Sun Mar 31, 2013 9:13 am

Code: Select all

put "2" into tValue
setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", tValue, "dword")
Does that work?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

glenn52
Posts: 25
Joined: Mon May 02, 2011 1:34 pm
Contact:

Re: setRegistry - DWORD

Post by glenn52 » Sun Mar 31, 2013 9:27 am

Simon wrote:

Code: Select all

put "2" into tValue
setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", tValue, "dword")
Does that work?
No. That generates the Livecode "can't find handler" error. :wink:

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: setRegistry - DWORD

Post by shaosean » Sun Mar 31, 2013 10:27 am

setRegistry is a function, so using get is the correct way (or an if statement).. Perhaps but the "2" in the setRegistry function instead of a variable..

Code: Select all

setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", "2", "dword")

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: setRegistry - DWORD

Post by magice » Sun Mar 31, 2013 5:06 pm

I ran into this problem a few months ago. I was trying to use a variable inside of a function and it kept generating an error. Since it represented user input, it needed it to be a variable. My solution was probably not the best, but it got me passed the problem. I just put the entire statement inside of a do statement and used the "&" to string together the function statement with the variable. Of course that can be a nightmare in itself. I'm sure there is an easier way, and I will be following this thread to see what the answer is.

In your case though I think the problem is in the registry value itself. I think you need to convert the "2" in tValue to 32 bit format.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: setRegistry - DWORD

Post by magice » Sun Mar 31, 2013 6:17 pm

Ignore my previous comments. I have been playing with this for some time, and I can't seem to get LC to send the value to the registry in a format that it can understand. In C++ there was always the annoying need to pass the pointer to the value of a dword entry instead of the value itself. I wonder if setRegestry function just cannot send data that way.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: setRegistry - DWORD

Post by Simon » Sun Mar 31, 2013 9:29 pm

got it:

Code: Select all

   put "2" into tValue
   get setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", binaryEncode("I",tValue), "dword")
  
works here.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

glenn52
Posts: 25
Joined: Mon May 02, 2011 1:34 pm
Contact:

Re: setRegistry - DWORD

Post by glenn52 » Sun Mar 31, 2013 11:28 pm

Simon wrote:got it:

Code: Select all

   put "2" into tValue
   get setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", binaryEncode("I",tValue), "dword")  
works here.
Simon
Thanks Simon, worked here too, now I know where my shoes are... :wink:

Thanks to everyone!

glenn52

Post Reply