Sign in to follow this  
Followers 0
JackMac4

hex/binary registry value conversion

5 posts in this topic

#1 ·  Posted (edited)

I've been scouring for a day or two now and am having some difficulty coming up with a good method to tackle a problem I have. I need to write a registry value in binary, which in itself is no problem. The value that I need to write needs to be converted from a string value - also not a big deal, but I need to manipulate this string in order for it to be properly formatted and that's where I'm stuck.

$file = "filename.iso"
$path = ";C:\Documents and Settings\All Users\Application Data\Program\"&$file
For $i = 0 to UBound($path)-1
    $value+=$path[$i]+Chr(0)
Next
RegWrite("HKEY_CURRENT_USER\Software\Program\Preferences\VirtualCD","VirtualCDDriveList","REG_BINARY", "0x"&Hex(StringtoBinary($value)))

So basically I'm needing to take the path and filename string, insert a null character in between every character, then convert it to hex value to write into the registry...

The problem thus far has been in dealing with the existing white space. I'm having difficulty properly converting this to hex and spacing it with nulls while not losing the spacing that exists due to the long path name.

Any help in conquering this problem would be most appreciated!

Edited by JackMac4

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$path=StringToASCIIArray("test") 
Dim $newpath = "" 
For $i = 0 to UBound($path)-1   
  $newpath += $path[$i]     
  $newpath += 0 
Next 
MsgBox(0,"",StringFromASCIIArray($newpath))

this simply yields me null - and is my attempt at adding the null values to just a regular string. could someone help steer me in the right direction here?

Edited by JackMac4

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

There is a NULL-Character after each char since the data is stored as Unicode with 2 bytes. I think you should do this:

$data = "WHATEVER THE DATASTRING SHOULD BE"

$data = StringToBinary($data, 2)
RegWrite("HKEY_CURRENT_USER\Software\Program\Preferences\VirtualCD","VirtualCDDriveList","REG_BINARY", $data)
;MsgBox(0, '', $data)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

There is a NULL-Character after each char since the data is stored as Unicode with 2 bytes. I think you should do this:

$data = "WHATEVER THE DATASTRING SHOULD BE"

$data = StringToBinary($data, 2)
RegWrite("HKEY_CURRENT_USER\Software\Program\Preferences\VirtualCD","VirtualCDDriveList","REG_BINARY", $data)
;MsgBox(0, '', $data)

Thank you so much! I believe that little nugget of information was exactly what I needed. I was hoping there was a simpler way of doing it!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0