Win32_PhysicalMedia SerialNumber 属性存在问题
我编写了以下代码来获取物理介质序列号,但在我的一台计算机中它返回 null。 有人知道问题是什么吗? 谢谢。
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
foreach( ManagementObject mo in searcher.Get() )
{
Console.WriteLine("Serial: {0}", mo["SerialNumber"]);
}
I wrote the following code to get the physical media serial number but in one of my computers it returns null instead.
Does anybody know what the problem is?
Thanks.
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
foreach( ManagementObject mo in searcher.Get() )
{
Console.WriteLine("Serial: {0}", mo["SerialNumber"]);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
序列号是可选的,由制造商定义,对于您的设备来说,它要么是空白的,要么不受驱动程序支持。
几乎所有硬盘驱动器都有序列号,但大多数 USB 式闪存棒没有(通常是成本问题)。我想大多数无品牌的 CD/DVD/BD 光盘也将是非序列化的。
The Serial Number is optional, defined by the manufacturer, and for your device it is either blank or unsupported by the driver.
Virtually all hard drives have a serial number, but most USB-style Flash memory sticks do not (generally a cost issue). I would imagine most unbranded CD/DVD/BD discs would also be non-serialized.
这是我使用的代码,序列号以某种方式返回原始,每对字符反转(奇怪),如果我以用户或管理员身份运行代码(更奇怪),使用 Win32_PhysicalMedia 会给出不同的结果 - Windows 7 Ultimate,VS 2008 年仅使用 VB:
Here is the code I used, the serial number somehow is returned raw with each pair of chars reversed (strange) and using Win32_PhysicalMedia gave different results if I ran the code as a user or an Administrator(more strange) - Windows 7 Ultimate, VS 2008 using VB only: