找回密码
 加入
搜索
查看: 2150|回复: 31

[AU3基础] 【已解决】如何将注册表REG_BINARY类型数据转换成字符串格式?

[复制链接]
发表于 2022-7-8 18:56:05 | 显示全部楼层 |阅读模式
本帖最后由 redapple2008 于 2022-7-9 10:59 编辑
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\LEN40A9\4&c0b3f9&0&UID8388688\Device Parameters]
"EDID"=hex:00,ff,ff,ff,ff,ff,ff,00,30,ae,a9,40,00,00,00,00,24,1a,01,04,a5,1f,\
  11,78,e2,28,65,97,59,54,8e,27,1e,50,54,00,00,00,01,01,01,01,01,01,01,01,01,\
  01,01,01,01,01,01,01,b4,3b,80,4a,71,38,34,40,50,3c,68,00,35,ad,10,00,00,18,\
  b4,3b,80,4a,71,38,34,40,50,3c,68,00,35,ad,10,00,00,18,00,00,00,0f,00,d1,09,\
  3c,d1,09,30,19,0a,00,0d,ae,d4,14,00,00,00,fe,00,4e,31,34,30,48,43,41,2d,45,\
  41,43,0a,20,00,0b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00
发表于 2022-7-14 16:28:44 | 显示全部楼层
redapple2008 发表于 2022-7-14 14:00
是啊,你有好的方法解决?

要看你抓什么信息, 分辨率还是型号,还是尺寸.
EDID数据有标准的
发表于 2022-7-9 14:57:56 | 显示全部楼层
本帖最后由 fybhwsx 于 2022-7-9 15:03 编辑
redapple2008 发表于 2022-7-9 10:58
测试没正确运行。

莫名奇妙,怎么个没正确运行?什么提示都没有?即使你注册表不存在也该返回项或值不存在的提示吧?!

哦哦,我弄错了,你是要转换。我以为要读写,不好意思。。

 楼主| 发表于 2022-7-8 18:57:12 | 显示全部楼层
使用_HexToSting函数转换后返回竟然是一个空的字符串。
发表于 2022-7-8 19:04:36 | 显示全部楼层
这个不可能能转换成字符串吧?!看看带有 01 及 00 的就知道!
发表于 2022-7-8 19:21:52 | 显示全部楼层
把“hex:”换成0x后面数值 , 和 \ 删掉。。
0x00ffff……
 楼主| 发表于 2022-7-8 19:33:22 | 显示全部楼层
本帖最后由 redapple2008 于 2022-7-8 19:40 编辑

显示不出来是什么情况?
#Region    ;IncludesHelper ADD
#Include <String.au3>
#include <StringConstants.au3>
#EndRegion ;IncludesHelper ADD
$KeyPath = "HKLM\SYSTEM\CurrentControlSet\Enum"
$INDEX = 57
$Computer = "."
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colSettings = $objWMIService.ExecQuery("SELECT DeviceID FROM Win32_PnPSignedDriver WHERE DeviceClass = 'MONITOR'")
For $objOperatingSystem In $colSettings
        $tmp = $objOperatingSystem.DeviceID
        $EDID = RegRead($KeyPath & $tmp & "\Device Parameters", "EDID")
        If $EDID <> "" Then
                                                $sString = BinaryMid($EDID,114,75)
$sString = _HexToString($sString )
ConsoleWrite(@CRLF&$sString &@CRLF)
 MsgBox(0, "12345", $sString )

        EndIf
Next
发表于 2022-7-8 19:41:05 | 显示全部楼层
本帖最后由 afan 于 2022-7-8 19:42 编辑

不是文本格式数据,140HCA-EAC  肉眼看的
 楼主| 发表于 2022-7-8 19:44:46 | 显示全部楼层
afan 发表于 2022-7-8 19:41
不是文本格式数据,140HCA-EAC  肉眼看的

没明白你的意思。这样的数据读不出来吗?
发表于 2022-7-8 19:47:49 | 显示全部楼层
redapple2008 发表于 2022-7-8 19:44
没明白你的意思。这样的数据读不出来吗?

3# chishingchan 版主已经告诉你了
 楼主| 发表于 2022-7-8 19:50:16 | 显示全部楼层
下面为c#的代码:没问题的
  public string GetMonitorInfo()
                {
                        string[] array = this.GetDisplayPNPDeviceID();
                        if (array.Length == 0)
                        {
                                string queryString = "SELECT DeviceID FROM Win32_PnPSignedDriver WHERE DeviceClass = 'MONITOR'";
                                array = this.GetWmiInfo(queryString).Split(new char[] { '/' });
                        }
                        List<string> list = new List<string>();
                        try
                        {
                                foreach (string str in array)
                                {
                                        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\" + str + "\\Device Parameters");
                                        byte[] array3 = (byte[])registryKey.GetValue("EDID");
                                        registryKey.Close();
                                        foreach (byte b in new byte[] { 75, 93, 111 })
                                        {
                                                if ((int)array3[(int)b] == Convert.ToInt32("FC", 16))
                                                {
                                                        byte[] bytes = array3.Skip((int)(b + 2)).Take(13).ToArray<byte>();
                                                        string text = Encoding.UTF8.GetString(bytes).Trim();
                                                        list.Add(text.Trim());
                                                }
                                        }
                                }
                        }
                        catch (Exception)
                        {
                        }
                        if (list.Count <= 0)
                        {
                                return this.GetWmiInfo("SELECT Name FROM Win32_DesktopMonitor");
                        }
                        return string.Join("/", list.ToArray());



发表于 2022-7-8 20:09:16 | 显示全部楼层
redapple2008 发表于 2022-7-8 19:50
下面为c#的代码:没问题的

你截取其中的文本部分显示当然可以(包括5#都是截取部分),整个二进制值并非文本格式数据。
 楼主| 发表于 2022-7-8 20:25:28 | 显示全部楼层
afan 发表于 2022-7-8 20:09
你截取其中的文本部分显示当然可以(包括5#都是截取部分),整个二进制值并非文本格式数据。

截取了,但没法显示出来,需要怎么操作让显示出来?
发表于 2022-7-8 23:14:08 | 显示全部楼层
redapple2008 发表于 2022-7-8 20:25
截取了,但没法显示出来,需要怎么操作让显示出来?

那你是获取或截取有问题

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2022-7-9 00:01:32 | 显示全部楼层
直接用正则
; $sBin 是读取的注册表二进制数据




                Local $sDescription = '' ;//读取型号/描述
                Local $aReg = StringRegExp($sBin,'(?i)FC[02]0((?:(?=..).)+?)0A[02]0',1)
                If Not @error Then
                        $sDescription = BinaryToString('0x' & $aReg[0],4)
                EndIf       


发表于 2022-7-9 00:08:58 | 显示全部楼层
zghwelcome 发表于 2022-7-9 00:01
直接用正则
; $sBin 是读取的注册表二进制数据

正则需要从字符串起始匹配,否则可能错位 (?i)^(?:..)*
发表于 2022-7-9 06:11:46 | 显示全部楼层
Local $iPID = Run('REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\LEN40A9\4&c0b3f9&0&UID8388688\Device Parameters" /v "EDID"', '', @SW_HIDE, $STDERR_MERGED)
ProcessWaitClose($iPID)
MsgBox(0, "12345", StdoutRead($iPID))

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-27 20:12 , Processed in 0.083899 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表