我正在尝试获取查看 Windows 注册表的 Acer 显示器的序列号。我在 Python 3 中使用以下代码解析注册表:
import winreg
from winreg import HKEY_LOCAL_MACHINE
subKey = "SYSTEM\CurrentControlSet\Enum\DISPLAY"
k = winreg.OpenKey(HKEY_LOCAL_MACHINE, subKey)
with winreg.OpenKey(HKEY_LOCAL_MACHINE, subKey) as k:
""""
Open the key 'HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY'
to get the info of all connected monitors
"""
i = 0
while True:
try:
with winreg.OpenKey(k, winreg.EnumKey(k, i)) as sk:
j = 0
while True:
try:
with winreg.OpenKey(sk, winreg.EnumKey(sk, j)) as ssk:
l = 0
while True:
try:
if (winreg.EnumKey(ssk, l) == "Control"):
try:
with winreg.OpenKey(ssk, "Device Parameters") as sssk:
strEDID = str(winreg.EnumValue(sssk, 0)[1])
try:
modelo = strEDID[strEDID.index("\\x00\\x00\\x00\\xfc") + len("\\x00\\x00\\x00\\xfc\\x00"):].split("\\")[0]
serie = strEDID[strEDID.index("\\x00\\x00\\x00\\xff") + len("\\x00\\x00\\x00\\xff\\x00"):].split("\\")[0]
except:
modelo = "Not Found"
serie = "Not Found"
print ("Modelo:", modelo)
print ("Serie:", serie, "\n")
fo = open("salTest.txt", "a")
fo.write(modelo + "\n")
fo.write(serie + "\n\n")
fo.close()
except OSError:
print ("Error")
break
else:
l += 1
except OSError:
break
j += 1
except OSError:
break
i += 1
except OSError:
break
结果,我在 cmd 窗口中得到如下输出:
Modelo: AL1716
Serie: L4802017396L
问题是“Serie”不是真正的序列号(Acer 显示器序列号有 22 个字符,看起来像“ETL480201781700F4B396L”)
有一种方法可以使用“Serie”和 SNID 构建真正的序列号也识别显示器。
以下是两个 Acer 显示器的示例:
S/N ORIGINAL: ETL48020178170 (0F4B)396L | # ETL480201781700F4B396L
------------------------------------------------------------------------------------
SNID: 8170 (0F4B)=03915 | 39 # 81700391539
S/N FROM SCRIPT: L4802017 396L | # L4802017396L
S/N ORIGINAL: ETL48020178170 (2C98)396L | # ETL480201781702C98396L
------------------------------------------------------------------------------------
SNID: 8170 (2C98)=11416 | 39 # 81701141639
S/N FROM SCRIPT: L4802017 396L | # L4802017396L
有人知道如何获取此信息吗?
谢谢!