Delphi:获取主板序列号时出现错误
有 2 个很好的示例如何获取序列号:如何在 Delphi 中获取主板 ID 或序列号?
它们都为我工作(Windows 7)。但对于 2 个人来说,他们就没有!
选项 1(Microsoft WMIScripting 库)返回无法在异常中处理的错误! (我尝试在异常中使用我的代码,但它没有执行)。操作系统 Windows 7:
选项 2 (Windows XP) - 不返回任何内容:无错误,无序列号。
有人可以解释为什么会这样吗?是否有工作代码可以做到这一点?
该链接中有一条评论:“@PRUZ 你知道我的第二条评论吗?我在其他计算机上检查了相同的代码,但返回“无”。这是怎么回事? – Himadri”
谢谢!!!
There are 2 good examples how to get a serial number: How to get motherboard id or serial number in Delphi?
All they work for me (Windows 7). But for 2 people they don't!
The Option 1 (Microsoft WMIScripting Library) returns an error which cannot be handled in an exception! (I tried to use my code in the exception but it was not performed). OS Windows 7:
The Option 2 (Windows XP) - returns nothing: no errors, no the serial number.
Can anybody explain why it is and is there a work code to do this?
There is a comment in that link: "@PRUZ And you know something about my second comment? that I check the same code in some other computer which returns 'none'. What's the matter with it? – Himadri"
Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@maxfax,第一个示例代码在 Windows xp 中不起作用,因为使用了自 Windows Vista 以来可用的
ItemIndex
属性,有关更多详细信息,请检查此 文章(导入 Microsoft WMIScripting 时要小心库
)。第二个片段必须在任何 Windows 系统中都能正常工作,因为直接使用属性名称访问 WMI 属性。现在,如果第二个选项未在任何计算机中检索序列号,只是因为 WMI 提供程序未公开此属性的信息。作为旁注,某些虚拟机(例如 VMWARE)将None
报告为序列号。更新
我刚刚在我的博客上写了一篇关于如何阅读 SMBios 的文章 (
Reading the SMBios Tables using Delphi
),使用此方法可以直接从 SMBios 获取主板的序列号表。@maxfax, the first sample code does not work in Windows xp because uses the
ItemIndex
property which is available since windows vista for more details check this article (Be careful when you import the Microsoft WMIScripting Library
). the second snippet must work ok in any Windows system, because access the WMI properties using the name of the property directly. Now if the second option does not retrieve a serial number in any machine just is because the WMI provider does not expose information for this property. as side note some Virtual Machines like VMWARE reportsNone
as serial number .Update
I just wrote an article on my blog about how read the SMBios (
Reading the SMBios Tables using Delphi
), using this method you get the serial number of the motherboard directly from the SMBios tables.