![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to write/change binary value in registry I'm going to change a large value in registry for example: const HKEY_LOCAL_MACHINE = &H80000002 strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Printers\FX Document Centre C250 PCL 6\PrinterDriverData" strComputer = "." iValues = xxxx Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") BinaryValueName = "PrinterData1" oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, BinaryValueName,iValues question is how to wire xxxx (iValuse) to a large vlaue, "PrinterData1"=hex:54,11,10,50,01,21,00,00,48,03,02,00,00,00,00,00,00,00,55,00,\ 6e,00,6b,00,6e,00,6f,00,77,00,6e,00,55,00,73,00,65,00,72,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 thanks for your help!!! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to write/change binary value in registry You send in an array. You can edit you list of values to create the array: Array1 = Array(84, 17, 16, ...etc. ) (Note that I wrote the values as decimal. You're recording byte data with a binary value and a byte is a numeric type.) You can also create the array and then fill in values. In the sample you posted it's mostly zeros, so that could work. If it were me, and I needed to do this more than once, I write a little script to format my array code. Maybe something that would let me drop a regedit file onto it and get working script code written to disk. Quote: > I'm going to change a large value in registry > for example: > const HKEY_LOCAL_MACHINE = &H80000002 > strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Printers\FX Document > Centre C250 PCL 6\PrinterDriverData" > strComputer = "." > iValues = xxxx > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & > strComputer & "\root\default:StdRegProv") > BinaryValueName = "PrinterData1" > oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, BinaryValueName,iValues > > question is how to wire xxxx (iValuse) to a large vlaue, > 00,\ Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > Quote: > 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 > > thanks for your help!!! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to write/change binary value in registry hello, how to format hex into decimal? here is the registry file ========= Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\FX Document Centre C250 PCL 6\PrinterDriverData] "PrinterData1"=hex:54,11,10,50,01,21,00,00,48,03,02,00,00,00,00,00,00,00,55,00,\ 6e,00,6b,00,6e,00,6f,00,77,00,6e,00,55,00,73,00,65,00,72,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ======================================================== "mayayana" wrote: Quote: > You send in an array. You can edit you list > of values to create the array: > > Array1 = Array(84, 17, 16, ...etc. ) > > (Note that I wrote the values as decimal. You're > recording byte data with a binary value and a byte > is a numeric type.) > > You can also create the array and then fill in values. > In the sample you posted it's mostly zeros, so that > could work. > > If it were me, and I needed to do this more than once, > I write a little script to format my array code. Maybe something > that would let me drop a regedit file onto it and get > working script code written to disk. > Quote: > > I'm going to change a large value in registry > > for example: > > const HKEY_LOCAL_MACHINE = &H80000002 > > strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Printers\FX Document > > Centre C250 PCL 6\PrinterDriverData" > > strComputer = "." > > iValues = xxxx > > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & > > strComputer & "\root\default:StdRegProv") > > BinaryValueName = "PrinterData1" > > oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, BinaryValueName,iValues > > > > question is how to wire xxxx (iValuse) to a large vlaue, > > > 00,\ Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > Quote: > > 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 > > > > thanks for your help!!! > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how to write/change binary value in registry Dim s s = "6E" MsgBox CByte("&H" & s) '-- A bit of quickie code (I'm not sure if this is the best method): Dim A1, s1, s2, i, i3, s3 ' If you take just the string of values you can use Replace to ' remove the "\" And returns: s1 = Replace(s1, "\", "") s1 = Replace(s1, vbCr, "") s1 = Replace(s1, vbLf, "") 'You then have a string that's just 00,6E,00 ....etc.. ' Next use: A1 = Join(s1, ",") ' Now you have an array of those string values, which ' you need to convert: For i = 0 to UBound(A1) Select Case A1(i) Case "00" A1(i) = 0 Case Else A1(i) = CByte("&H" & A1(i)) End Select Next ' That should give you an array of byte values that you ' can send in the function. ' Note: I didn't test all of this and sometimes I find that ' VBS seems to have trouble fiddling with an array value in ' the array. If A1(i) = CByte("&H" & A1(i)) doesn't ' work then try: s3 = A1(i) i3 = CByte("&H" & s2) A1(i) = i3 ' You can also write a new array if necessary, dimming ' it to UBound(A1) and writing each numeric value to ' your new array. That seems cleaner to me, since you ' want a string array to become a byte array, but since ' VBS array values are variants it shouldn't matter. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: how to write/change binary value in registry 2nd post. This might be a bit clearer. I had a couple of typos in the first post and also discovered a tricky bug: If you don't remove the last comma in your string then it won't split properly. (I should have said Split instead of Join. Sorry if the first sample was confusing. I answered that post on only about half my required morning coffee allotment.) This code below works. I used a partial sample of your string to demonstrate it. ---------------- Dim s, A1, A2(), i2, s2, i3 s = "54,11,10,50,01,21,00,00,48,03,02,00,00,00,00,00,00,00,55,00,\6e,00,6b,00,6e ,00,6f,00,77,00,6e,00,55,00,73,00,65,00,72,00,00,00,00,00,00,\" '-- remove "\" and returns: s = Replace(s, "\", "") '-- remove Cr and Lf separately, in case return is not vbCrLf: s = Replace(s, vbCr, "") s = Replace(s, vbLf, "") '-- remove any trailing comma: If Right(s, 1) = "," Then s = Left(s, (len(s) - 1)) '-- convert to array: A1 = Split(s, ",") ReDim A2(UBound(A1)) For i2 = 0 to UBound(A1) If A1(i2) = "00" Then A2(i2) = 0 Else A2(i2) = CByte("&H" & A1(i2)) End If Next '-- Array A2 is now prepared to send in function call. MsgBox A2(0) '-- shows 84, decimal version of hex 54. ----------------------- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can't write to registry | Vista account administration | |||
| Copy a binary registry value to another value. | VB Script | |||
| Adding new String and Binary valules to registry | PowerShell | |||
| Registry Data REad Write Error | Vista hardware & devices | |||
| Registry Read/Write Security/Permissions | Vista General | |||