Re: Parsing binary values in the registry



Thank you for your input. I will give your code a try. My other question is
how to take a string variable that could concievably be up to 300
characters, and split that into either an array or multiple variables for
every 32 characters within the original varable. So if the original variable
holds a 96 character string, how can I easily convert that to an array or
three variables each containing 32 characters from the original variable.

example:

a = "96 character string"

a1 = "first 32 characters"
a2 = "next 32 characters"
a3 = "last 32 characters"
"mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx> wrote in message
news:sscye.3612$aY6.3085@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> If I understand that correctly:
> You're getting a unicode string as an array
> of bytes and you want to get the ANSI path
> string from that?
> So you get a numeric array like 87 00 67 00 68....?
>
> Assuming that ABytes is what was returned by
> GetBinaryValue. Also assuming that VBS can
> handle that byte array. I don't have a byte array handy to
> test this but it seems like it should work:
>
> Dim A2(), U1, i
>
> U1 = Ubound(ABytes)
> Redim A2(U1 \ 2)
> For i = 0 to U1 Step 2
> A2(i) = Chr(Abytes(i))
> Next
>
> PathString = Join(A2, "")
>
> What that does is to create an array half the size
> of your byte array, then step through the byte array,
> getting every second byte to skip the 00 bytes. Each
> of those is converted to an ANSI character and added
> to the A2 array. Once that's done you need only use
> Join on the A2 array to get your string.
>
> I'm not sure if that answers the first question. It sounds
> like you want to split an array of characters, but you
> say "an array of 32 length variables". What does that
> mean?
> --
> --
> Jim Gregg <jpgregg@xxxxxxx> wrote in message
> news:#uD72erfFHA.3940@xxxxxxxxxxxxxxxxxxxxxxx
>> Hello all,
>>
>> I have 2 questions if anyone can assist. First, I am wondering what is
>> the
>> best way to split a variable length value into an array of 32 length
>> variables. The size of the initial array can change from 32 to whatever.
>> Also, there is no splitting character such as tab or space. The initial
>> variable is just a series of values.
>>
>> Second, how can I take a variable length value and split it into an array
>> containing variables that have 4 characters. So, I need to take that long
>> value, take the first 4 characters, put that in a variable, go back to
>> the
>> original value, get the next 4, rinse and repeat. These 4 charatcer
>> values
>> are hex to unicode conversion, so I need to take the first two characters
>> from each 4 digit block and convert it to decimal and finally a
>> character.
>> Basically, I am trying to build a file path from a binary value in the
>> registry. Here is some example code:
>>
>> It is a bit of a mess at this time as I am just trying to write sections
> and
>> then bring it all together at the end:
>>
>> Const HKEY_CURRENT_USER = &H80000001
>>
>> strComputer = "."
>> Set StdOut = WScript.StdOut
>>
>> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
>> strComputer & "\root\default:StdRegProv")
>>
>> '*******************************************************
>> 'This section gets the default profile in Outlook
>> '*******************************************************
>>
>> strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
> Messaging
>> Subsystem\Profiles"
>> strValueName = "DefaultProfile"
>>
>> oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath, _
>> strValueName,strValue
>>
>> strProfile = strValue
>> StdOut.WriteLine strProfile
>>
>> '*******************************************************
>> 'This section gets each of the keys that hold PST file paths
>> '*******************************************************
>>
>> strProfilePath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
>> Messaging Subsystem\Profiles\" & strProfile &
>> "\9207f3e0a3b11019908b08002b2a56c2"
>> strProfileName = "01023d00"
>>
>> oReg.GetBinaryValue HKEY_CURRENT_USER,strProfilePath, _
>> strProfileName,strValue2
>> StdOut.WriteLine strProfilePath & "\" & strProfileName
>>
>>
>> For i = lBound(strValue2) to uBound(strValue2)
>>
>> If Len((Hex(strValue2(i)))) <> 2 then
>> strPathKeys = strPathKeys & "0" & Hex(strValue2(i))
>>
>> Else
>> strPathKeys = strPathKeys & Hex(strValue2(i))
>> End If
>> Next
>>
>> stdOut.WriteLine Len(strPathKeys)
>> stdOut.WriteLine strPathKeys
>>
>> '**********************************************************
>> 'This section breaks the above info into 32 bit values
>> '**********************************************************
>> No Code yet
>> '**********************************************************
>> '**********************************************************
>> 'The below section reads the reg keys that contain the binary version of
> the
>> file path
>>
>> strPSTPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
> Messaging
>> Subsystem\Profiles\" & strProfile & "\" & Left(strPathKeys, 32)
>> strPSTKey = "001f6700"
>>
>> oReg.GetBinaryValue HKEY_CURRENT_USER,strPSTPath, _
>> strPSTKey,strValue3
>> StdOut.WriteLine strPSTPath & "\" & strPSTKey
>>
>> For i = lBound(strValue3) to uBound(strValue3)
>>
>> If Len((Hex(strValue3(i)))) <> 2 then
>> strPSTKeys = strPSTKeys & "0" & Hex(strValue3(i))
>>
>> Else
>> strPSTKeys = strPSTKeys & Hex(strValue3(i))
>> End If
>> Next
>>
>> stdOut.WriteLine Len(strPSTKeys)
>> stdOut.WriteLine strPSTKeys
>> '*************************************************************
>> 'Testing Hex to Decimal, then Decimal to CHR
>> decimal = CLng("&H" & left(strPSTKeys,2))
>> stdOut.WriteLine decimal
>> stdOut.WriteLine Chr(decimal)
>>
>>
>
>


.



Relevant Pages

  • Re: fgets question
    ... documentation didn't say if fgets put \0 after a string literal. ... fgets() has nothing at all to do with string literals. ... within the bounds of the array, then it is not a string. ... strlenon an array of characters that is not a string, ...
    (comp.lang.c)
  • Re: Help creating a random string in Perl
    ... can pick one of the 7 characters in my source string) by using "print ... third and fourth characters to and check that the random number hasn't ... shuffling the array ... The idea here is to swap the current cell with some cell ...
    (perl.beginners)
  • Re: newbie: mapping CHARACTER*2 to INTEGER*2
    ... that destroys the Chinese characters in my input. ... effect the conversion required. ... If MOLD is an array and SIZE is omitted, ... represent the values 4.0 and 1082130432 as the string of binary digits ...
    (comp.lang.fortran)
  • Re: Array reinitialize
    ... |> | by a character string literal, ... |> | initialize the elements of the array." ... | is really 21 characters long. ... an array via an aggregate initialiser, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: chars
    ... The first six characters of that array form a string. ... You also seem to be confusing character literals with string literals. ...
    (comp.lang.c)