Get the new PortableApps.com Platform 10.0: Gorgeous themes, a full portable app store and advanced functionality
Announcing the World's Best Flash Drive: The PortableApps.com Companion | Did you see a malware warning on Friday?

Convert string to hex for registry write

qy100fou - March 18, 2010 - 5:32pm

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


( categories: )

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

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.

!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

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.