You are here

Convert string to hex for registry write

5 posts / 0 new
Last post
qy100fou
Offline
Last seen: 14 years 2 months ago
Joined: 2010-03-18 18:16
Convert string to hex for registry write

Hi,

I'm a newbie in NSIS developement and I've few problems with registry.

I need to convert the following string "$EXEDIR\App\Chainer\VstPlugins" to hex values for import in the registry like that :

WriteRegBin HKCU "Software\Xlutop\Chainer\1.0" "VstPaths" xxxxxxxx

where xxxxxxxx must be replaced by the hex value of "$EXEDIR\App\Chainer\VstPlugins".

I've found the registry function ${registry::StrToHex} but I have no idea how to use it.

Here's my code :

${registry::StrToHex} "$EXEDIR\App\Chainer\VstPlugins" $var

Thanks you

Mark Sikkema
Offline
Last seen: 12 years 9 months ago
Developer
Joined: 2009-07-20 14:55
You need to include the

You need to include the registry plug-in first:

!include Registry.nsh
...
Section...
....
${registry::StrToHex} "$EXEDIR\App\Chainer\VstPlugins" $var
...
${registry::Unload}
SectionEnd

Have a look in the 'Other\Source\' folders of some of the portable apps from this site. To have some examples.
Like 7-ZipPortable for dealing with the registry.

Formerly Gringoloco
Windows XP Pro sp3 x32

qy100fou
Offline
Last seen: 14 years 2 months ago
Joined: 2010-03-18 18:16
Thank you for help me! I've

Thank you for help me!
I've tried to use my source with your code but I've still an error while compiling. Here's my code :

!include "Registry.nsh"
...
Function ImportHexKeys
	${registry::StrToHex} "$EXEDIR\App\Chainer\VstPlugins" $var	
	${registry::Write} "HKEY_CURRENT_USER\Software\Xlutop\Chainer\1.0" "VstPaths" "$var" "REG_BINARY" $R0
Sleep 30
${registry::Unload}
FunctionEnd

..and the error

File: "Registry.dll"->"$PLUGINSDIR\Registry.dll" 0/16384 bytes
Plugin Command: _StrToHex [$EXEDIR\App\Chainer\VstPlugins]
Usage: Pop $(user_var: output)
Error in macro registry::StrToHex on macroline 2

I have looked for 7zip portable source but it's a bit difficult for a newbie like me to understand all fucntions.

Mark Sikkema
Offline
Last seen: 12 years 9 months ago
Developer
Joined: 2009-07-20 14:55
!include
!include "Registry.nsh"
...
Function ImportHexKeys
	${registry::StrToHex} "$EXEDIR\App\Chainer\VstPlugins" $R1
	${registry::Write} "HKEY_CURRENT_USER\Software\Xlutop\Chainer\1.0" "VstPaths" "$R1" "REG_BINARY" $R0
Sleep 30
${registry::Unload}
FunctionEnd

$0 - $9 & $R0 - $R9 are predeclared variables.
If there is any need to declare an additional one, use the following before starting a function/section:

Var $AnyName ; $var was just an example

And read the NSIS usermanual 'NSIS\NSIS.chm', you should be able to come a long way by trail & error !!!

Formerly Gringoloco
Windows XP Pro sp3 x32

qy100fou
Offline
Last seen: 14 years 2 months ago
Joined: 2010-03-18 18:16
Thank you again

Thank you again Gringoloco!

This is working now.

I've also used the code in another post of you "Registry Keys in Vista & Windows 7" to resolve some other problems.

Log in or register to post comments