Skip to content
⌘ NSIS Forum Archive

Problem using WriteRegDWORD

4 posts

Install-O-Matic#

Problem using WriteRegDWORD

I am trying to write an integer stored in a variable into a REG_DWORD and I am having some problems. The line I am using to store this integer is:
WriteRegDWORD HKLM "Software\Classes\ClassName" "class_key" $ClassKey

$ClassKey holds an 8 character decimal number entered by the user. If $ClassKey is “11111111” then it is stored into the registry OK. If $ClassKey is “01111111” (which is 0x1f447) then what is actually stored in the registry is 299593 (which is 0x49249)
If $ClassKey is “1111111”, (no leading 0) then it will be stored correctly. I have to allow for the user to enter leading zeros.
Can someone tell me what I am doing wrong and how I can get around it?

Thanks.
glory_man#
It is all right.
01111111 (octal) = 0x49249 (hexadecimal).

“01111111” (which is 0x1f447)
Why? 🧟

EDIT:
0x1f447 (hex) = 0372107 (octal) - to my mind.
Install-O-Matic#
Thanks glory_man. I should have realized that.
Is there a command or macro to remove leading zeros from a string, or do I just need to create my own string modifying function?
Red Wine#
You may use registry plugin to solve that. EX
${registry::Write} "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ClassName" "class_key" "01111111" "REG_DWORD" $R0