我正在尝试从注册表中提取一个二进制格式的值并将其转换为字符串并将其输入到文本框中。当我运行我的代码时,文本框是空的。我检查了注册表,那里有一个二进制值,并检查了 VB 中的代码。下面是我获取值并将其转换并将其添加到文本框中的代码。
Dim LANDeskVirus As String = CStr(My.Computer.Registry.GetValue _
("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LANDesk\ManagementSuite\WinClient\Antivirus", _
"PatternFileDate", Nothing))
Dim LANDeskVirusDefintion As String = Convert.ToString(LANDeskVirus)
Dim BinaryText As String = LANDeskVirusDefintion
Dim Characters As String = Regex.Replace(BinaryText, "[^01]", "")
Dim ByteArray((Characters.Length / 8) - 1) As Byte
For Index As Integer = 0 To ByteArray.Length - 1
ByteArray(Index) = Convert.ToByte(Characters.Substring(Index * 8, 8), 2)
Next
TextBox1.Text = (ASCIIEncoding.ASCII.GetString(ByteArray))