这是一个名为" Hex"的字符串。值如下:
43,00,23,00,01
现在我尝试将其写入二进制注册表项,为此我需要使用以下命令:
arrValues = Array(1,2,3)
我已经取代了" 1,2,3"用" Hex"但它似乎无法正常工作:
arrValues = Array(Hex)
这意味着它无法解析" Hex"作为一个数组,所以我需要将其转换为数组,然后在上面的命令中使用它。你能告诉我怎么办?
以下是我用来编写二进制值的脚本:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject _
("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\DownloadManager\FoldersTree\Compressed"
strValueName = "pathW"
arrValues = Array(1,2,3)
errReturn = objRegistry.SetBinaryValue _
(HKEY_CURRENT_USER, strKeyPath, strValueName, arrValues)
答案 0 :(得分:3)
strings
。在代码中:
>> WScript.Echo Hex(15)
>> s = "43,00,23,00,01,FF"
>> a = Split(s, ",")
>> WScript.Echo TypeName(a), TypeName(a(0)), Join(a, "-")
>> For i = 0 To UBound(a) : a(i) = CByte("&H" & a(i)) : Next
>> WScript.Echo TypeName(a), TypeName(a(0)), Join(a, "-")
>>
F
Variant() String 43-00-23-00-01-FF
Variant() Byte 67-0-35-0-1-255
(读取arrValues)
更新评论/编辑问题:
所以你没有像我告诉你那样做:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject _
("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "TEMP"
strValueName = "pathW"
arrValues = Split("43,00,23,00,01,FF", ",")
For i = 0 To UBound(arrValues) : arrValues(i) = CByte("&H" & arrValues(i)) : Next
errReturn = objRegistry.SetBinaryValue _
(HKEY_CURRENT_USER, strKeyPath, strValueName, arrValues)