Page 1 of 1

setRegistry - DWORD

Posted: Sun Mar 31, 2013 6:17 am
by glenn52
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?

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 8:11 am
by Simon
ooops?
get... err don't need that.
setRegistry kinda sounds like English.


Simon

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 8:51 am
by glenn52
Simon wrote:ooops?
get... err don't need that.
setRegistry kinda sounds like English.
Simon
:? errr.. what?

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 9:02 am
by Simon
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

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 9:07 am
by glenn52
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:

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 9:13 am
by Simon

Code: Select all

put "2" into tValue
setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden", tValue, "dword")
Does that work?

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 9:27 am
by glenn52
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:

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 10:27 am
by shaosean
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")

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 5:06 pm
by magice
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.

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 6:17 pm
by magice
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.

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 9:29 pm
by Simon
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

Re: setRegistry - DWORD

Posted: Sun Mar 31, 2013 11:28 pm
by glenn52
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