Reading REG_BINARY Keys with RegObj.dll 
Author Message
 Reading REG_BINARY Keys with RegObj.dll

I am trying to read a key of data type REG_BINARY, but I am having
problems.  The value is 06 00 09 00 00 00.  Basically, it appears to be
an array:

IsArray(objRegKey.Values(ValueName).Value) returns "True"
LBound(objRegKey.Values(ValueName).Value) returns "0"
UBound(objRegKey.Values(ValueName).Value) returns "5"
VarType(objRegKey.Values(ValueName).Value) returns "8209"
   8209 = 8192 (array) + 17 (byte) - an array of bytes

But any access to any elements of the array fail with the error "Type
mismatch" (code: 800A000D).  How do I access REG_BINARY registry types,
and more specifically, how do I handle that data?

--
Rick Kasten, MCSE         SysAdmin Consultant
Collective Technologies   http://www.*-*-*.com/

Sent via Deja.com
http://www.*-*-*.com/



Tue, 01 Jul 2003 02:04:34 GMT  
 Reading REG_BINARY Keys with RegObj.dll
    VBS doe not have functions to handle VT_UI1|VT_ARRAY data type. You can
use some third-party component (see ByteArray class,
http://www.pstruh.cz/help/ScptUtl/cl46.htm)

    You can also work with the data using multibyte string functions,
ADODB.Recordset or ADODB.Stream. See
http://www.pstruh.cz/tips/detpg_binarytostring.htm

Antonin Foller
PSTRUH Software
http://www.pstruh.cz


Quote:
> I am trying to read a key of data type REG_BINARY, but I am having
> problems.  The value is 06 00 09 00 00 00.  Basically, it appears to be
> an array:

> IsArray(objRegKey.Values(ValueName).Value) returns "True"
> LBound(objRegKey.Values(ValueName).Value) returns "0"
> UBound(objRegKey.Values(ValueName).Value) returns "5"
> VarType(objRegKey.Values(ValueName).Value) returns "8209"
>    8209 = 8192 (array) + 17 (byte) - an array of bytes

> But any access to any elements of the array fail with the error "Type
> mismatch" (code: 800A000D).  How do I access REG_BINARY registry types,
> and more specifically, how do I handle that data?

> --
> Rick Kasten, MCSE         SysAdmin Consultant
> Collective Technologies   http://www.colltech.com

> Sent via Deja.com
> http://www.deja.com/



Tue, 01 Jul 2003 05:31:55 GMT  
 Reading REG_BINARY Keys with RegObj.dll
That second link explained how to do it, but it needed a little
tweaking.  My data uses numbers < Asc(32), so converting them to Chr()
did me no good printing them out.  I just left the Chr() part out, and
that was it.

Thanks!



Quote:
>     VBS doe not have functions to handle VT_UI1|VT_ARRAY data type.
You can
> use some third-party component (see ByteArray class,
> http://www.pstruh.cz/help/ScptUtl/cl46.htm)

>     You can also work with the data using multibyte string functions,
> ADODB.Recordset or ADODB.Stream. See
> http://www.pstruh.cz/tips/detpg_binarytostring.htm

> Antonin Foller
> PSTRUH Software
> http://www.pstruh.cz



> > I am trying to read a key of data type REG_BINARY, but I am having
> > problems.  The value is 06 00 09 00 00 00.  Basically, it appears
to be
> > an array:

> > IsArray(objRegKey.Values(ValueName).Value) returns "True"
> > LBound(objRegKey.Values(ValueName).Value) returns "0"
> > UBound(objRegKey.Values(ValueName).Value) returns "5"
> > VarType(objRegKey.Values(ValueName).Value) returns "8209"
> >    8209 = 8192 (array) + 17 (byte) - an array of bytes

> > But any access to any elements of the array fail with the
error "Type
> > mismatch" (code: 800A000D).  How do I access REG_BINARY registry
types,
> > and more specifically, how do I handle that data?

> > --
> > Rick Kasten, MCSE         SysAdmin Consultant
> > Collective Technologies   http://www.colltech.com

> > Sent via Deja.com
> > http://www.deja.com/

--
Rick Kasten, MCSE         SysAdmin Consultant
Collective Technologies   http://www.colltech.com

Sent via Deja.com
http://www.deja.com/



Tue, 01 Jul 2003 06:13:53 GMT  
 Reading REG_BINARY Keys with RegObj.dll
Treat it as a string of bytes instead of an array.

Here's a .wsf example of how to get it into the same form that the
WshShell.RegRead method returns (a variant array with each element being a
variant of subtype byte).

For this example I used regedit to manually create
"HKEY_CURRENT_USER\MyKey\binValue" with a value of "11 22 33 44".

<job>
<object id="reg" progid="regobj.registry" reference="yes" />
<script language="VBScript">

set regKey = reg.RegKeyFromString("\HKEY_CURRENT_USER\MyKey")
theBinaryValue = regKey.Values("binValue").Value

redim byteArray(lenb(theBinaryValue)-1)

for n = 1 to lenb(theBinaryValue)
  byteArray(n-1) = cbyte(ascb(midb(theBinaryValue,n,1)))
next

msgbox hex(byteArray(0))

</script>
</job>

Of course, this is a one way conversion...  You can't create a true byte
array (TypeName --> Byte()) with just script.

But there is a free MS component that is very useful for dealing with binary
data in script.  It was supposed to be included in the ADSI SDK (but didn't
make it).

Q250344 - SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
http://support.microsoft.com/support/kb/articles/Q250/3/44.ASP

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


Quote:
> I am trying to read a key of data type REG_BINARY, but I am having
> problems.  The value is 06 00 09 00 00 00.  Basically, it appears to be
> an array:

> IsArray(objRegKey.Values(ValueName).Value) returns "True"
> LBound(objRegKey.Values(ValueName).Value) returns "0"
> UBound(objRegKey.Values(ValueName).Value) returns "5"
> VarType(objRegKey.Values(ValueName).Value) returns "8209"
>    8209 = 8192 (array) + 17 (byte) - an array of bytes

> But any access to any elements of the array fail with the error "Type
> mismatch" (code: 800A000D).  How do I access REG_BINARY registry types,
> and more specifically, how do I handle that data?

> --
> Rick Kasten, MCSE         SysAdmin Consultant
> Collective Technologies   http://www.colltech.com

> Sent via Deja.com
> http://www.deja.com/



Tue, 01 Jul 2003 07:41:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. regobj.dll key rename

2. Newbie needs help in reading installed programs from the registry using RegObj.dll

3. Reading binary registry values using regobj.dll

4. Newbie needs help in reading installed programs from the registry using RegObj.dll

5. Newbie needs help in reading installed programs from the registry using RegObj.dll

6. RP: Need help - reading/writing binary values using regobj.dll

7. Need help - reading/writing binary values using regobj.dll

8. Newbie needs help in reading installed programs from the registry using RegObj.dll

9. RP: Need help - reading/writing binary values using regobj.dll

10. RegObj & REG_BINARY

11. How to read REG_BINARY value from remote registry? (regobj.dll)

12. I need documentation on how to use RegObj.dll (registry manip dll)

 

 
Powered by phpBB® Forum Software