不使用 WMI 访问主板信息
我需要在多个进程的应用程序中访问主板标识(序列号、制造商等)。 我已经能够使用 WMI 成功查询此信息,但我正在寻找替代方案。
如果您想了解情况:
我有一些应用程序行为根据硬件配置而有所不同,或者如果设置特定的环境变量(用于测试目的)。
bool IsVideoCardDisplay = ( getenv("Z_VI_DISPLAY") || !QueryWmiForSpecialBoard() ) ? false : true;
设置环境变量后,不需要 WMI 查询——应用程序可以正常运行。 但是,当环境变量不存在时,我的应用程序的某些组件在需要进行 WMI 查询时无法启动。 我怀疑 WMI 调用可能会产生一些副作用(每个进程最多只发生一次。这就是我寻求替代方法的原因。
I need to access motheroard identification (serial, manufacture, etc) in my application on multiple processes. I have been able to successfully query this using WMI, but I'm looking for an alternative.
If you care to know situation:
I have some application behavior that is different depending on the hardware configuration, or if a particular environment variable is set (for testing purposes).
bool IsVideoCardDisplay = ( getenv("Z_VI_DISPLAY") || !QueryWmiForSpecialBoard() ) ? false : true;
When the environment variable is set the WMI query isn't necessary--the application runs fine. However, when the environment variable is not present some of the components of my app fail to launch when is necessary to make the the WMI queries. I suspect that there may be some side effects of the WMI calls (which only a maximum of happen once per processes. This is why I'm seeking an alternative way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Vista+ 中,您可以使用
GetSystemFirmwareTable
API 用于访问 SMBIOS 表并解析它们以获得[可能可用的]序列号和其他标识字符串和值。特别是,您可以访问主板数据,包括供应商和序列号:
In Vista+ you can use
GetSystemFirmwareTable
API to access SMBIOS tables and parse them out to obtain [possibly available] serial numbers and other identification strings and values.In particular you can access motherboard data, including vendor and S/N:
显然没有办法做到这一点,这是不幸的。
Apparently there is no way to do this, which is unfortunate.
该信息由 CPUID 指令提供。 以下链接为您提供了一个程序,该程序使用该指令来公开执行该指令的结果。
cpuid GNU 程序
That information is provided by the CPUID instruction. The following link provides you with a program that uses this instruction to expose the results of executing the instruction.
cpuid GNU program