Windows Vista Forums

how to write/change binary value in registry
  1. #1


    lasso Guest

    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 SpecsSystem Spec

  2. #2


    mayayana Guest

    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.

    > 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 SpecsSystem Spec

  3. #3


    lasso Guest

    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:

    > 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.
    >

    > > 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 SpecsSystem Spec

  4. #4


    mayayana Guest

    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 SpecsSystem Spec

  5. #5


    mayayana Guest

    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 SpecsSystem Spec

how to write/change binary value in registry problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot write to the registry at all TonyMacaroni Vista account administration 1 11 Oct 2009
Can't write to registry vmwebsites Vista account administration 4 29 Sep 2009
Copy a binary registry value to another value. Oldguard VB Script 3 03 Sep 2009
Adding new String and Binary valules to registry hantana PowerShell 2 16 Oct 2008
Impossible to write license information in the registry ckalan1 Vista General 1 30 Jun 2006