2

我有字符串:

46-C9-08-B6-E8-F3-47-CF-53-2A-77-02-C9-19-7F

我想把它变成一个数组,所以它看起来像这样:

{&H46, &HC9, &H8, &HB6, &HE8, &HF3, &H47, &HCF, &H53, &H2A, &H77, &H2, &HC9, &H19, &H7F}

完成的行将是这样的:

My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Bohemia Interactive Studio\ArmA 2 OA", "KEY", New Byte() {&H46, &HC9, &H8, &HB6, &HE8, &HF3, &H47, &HCF, &H53 , &H2A, &H77, &H2, &HC9, &H19, &H7F}, RegistryValueKind.Binary)

它将作为REG_BINARY类型插入注册表。

4

1 回答 1

0
Dim s As String= "46-C9-08-B6-E8-F3-47-CF-53-2A-77-02-C9-19-7F"
Dim parts As String() = s.Split(New Char() {"-"})        
Dim byteArray(parts.Length - 1) As Byte

For i As Integer = 0 To parts.Length - 1
    byteArray(i) = Convert.ToByte(parts(i), 16)
Next
于 2013-02-20T01:37:51.607 回答