- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想获取硬盘序列号。我该怎么做?我尝试了两个代码,但我没有得到
StringCollection propNames = new StringCollection();
ManagementClass driveClass = new ManagementClass("Win32_DiskDrive");
PropertyDataCollection props = driveClass.Properties;
foreach (PropertyData driveProperty in props)
{
propNames.Add(driveProperty.Name);
}
int idx = 0;
ManagementObjectCollection drives = driveClass.GetInstances();
foreach (ManagementObject drv in drives)
{
Label2.Text+=(idx + 1);
foreach (string strProp in propNames)
{
//Label2.Text+=drv[strProp];
Response.Write(strProp + " = " + drv[strProp] + "</br>");
}
}
在这个中我没有得到任何唯一序列号。
第二个是
string drive = "C";
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
disk.Get();
Label3.Text = "VolumeSerialNumber="+ disk["VolumeSerialNumber"].ToString();
我在这里得到 VolumeSerialNumber
。但它不是独一无二的。如果我格式化硬盘,这将会改变。我怎样才能得到这个?
最佳答案
嗯,看看你的第一组代码,我想你已经检索到(也许?)硬盘驱动器模型。序列号来自 Win32_PhysicalMedia
。
获取硬盘型号
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach(ManagementObject wmi_HD in searcher.Get())
{
HardDrive hd = new HardDrive();
hd.Model = wmi_HD["Model"].ToString();
hd.Type = wmi_HD["InterfaceType"].ToString();
hdCollection.Add(hd);
}
获取序列号
searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
int i = 0;
foreach(ManagementObject wmi_HD in searcher.Get())
{
// get the hard drive from collection
// using index
HardDrive hd = (HardDrive)hdCollection[i];
// get the hardware serial no.
if (wmi_HD["SerialNumber"] == null)
hd.SerialNo = "None";
else
hd.SerialNo = wmi_HD["SerialNumber"].ToString();
++i;
}
希望这有帮助:)
关于c# - 获取硬盘序列号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4084402/
我一直在阅读此处的一些帖子和网络上的文章,但我无法为我的应用程序描绘一个基于串行 key 的系统。 http://www.brandonstaggs.com/2007/07/26/implementi
我使用 Win32_BaseBoard SerialNumber 属性来获取主板序列号并且它在大部分时间都可以工作,但有时在某些计算机中我会得到 SerialNumber = "Base Board
我有以下数据: ID;NAME;SKILL 1;JOE;XML 1;JOE;JAVA 1;JOE;ORACLE 2;JOHN;JAVA 2;JOHN;API 我需要一个能给我这个结构的计数器: ID;
我有一个数据库,其中所有内容都与外键链接,因此 Postgres 确切地知道数据库是如何布局的。 假设我有 Table1 和 Table2。 Table1 有 3 个字段:RID、table2_rid
我尝试从多播流中计算 RTP 序列号并确定丢失的包。 请看下面的C代码: int sock, bytesRead; char buffer[MAXBUFSIZE]; uint16_t seq = 0;
我正在写一篇关于 TLS 的大学论文,有人问我为什么 TLS 序列号计数器是 64 位数字,而 TLS 在其消息中仅使用 32 位序列号。我环顾四周,甚至检查了 RFC,但到目前为止我一无所获。谁能帮
我正在尝试从 Android TV 添加 Chromecast 以转换开发设备列表,但是... 在尝试获取设备序列号时,电视上显示“0123456789ABCDEF”。我试图将它添加到列表中,但随后我
为什么我们需要TCP头中的序列号和下一个序列号字段? 下面是使用 wireshark 捕获的数据包中的 TCP header 。 最佳答案 首先,Wireshark 中 [brackets] 中的字段
我正在为我编写的软件编写自己的序列号验证/保护。 假设序列号验证器正在使用模式匹配...一旦序列号被验证,我如何更改程序本身以便它不再要求用户提供序列号? 我真的不想创建一个单独的许可文件。有没有办法
我想在列表中找到与正则表达式匹配的所有元素。为了减少正则表达式匹配的次数,我通过连接以空格分隔的元素创建了一个字符串,如下所示: list_a = ["4123", "7648", "afjsdn",
我们目前使用Rad Studio 2007,并希望很快升级到Delphi XE! 有人知道我们如何查看安装 Rad Studio 2007 时使用的序列号吗? 问候,彼得 最佳答案 “Rad Stud
调查数据表(survey_data)的样子 groupid| res_q_1| resp_q_2 -------|--------|---------- 12 | 1 |61 12
如何以编程方式获取 Google Glass 的 14 字符字母数字(如 LGGXXXXXXXXXXX)序列号? 最佳答案 看起来您可以通过检索值 android.os.Build.SERIAL 轻松
我正在开发一个项目,发送串行数据来控制 LED 灯的动画,这需要与动画引擎保持同步。似乎有一个大的串行写入缓冲区(OSX(POSIX)+ FTDI 芯片组 USB 串行设备),因此无需手动限制对 wr
我正在 Linux 下编写 C/C++ 客户端-服务器程序。假设一条消息m要从客户端发送到服务器。 Is it possible for the client to read the TCP sequ
方法一: 在给出的输入CD-KEY(序列号)的界面中,输入你已经安装的windows server 2003 的CD-KEY(序列号)即可以继续安装,而不是SQL 2000的CD-KEY
我想将xml数据存储到hive表中,XML数据: 1266 /: 61%used(9714MB/15975MB) ( / Disk Usage zab
我有一个遗留表,其自然键的一部分是一个名为 _IDENTIFIER 的列创建一个名为 _ID 的代理键似乎会让人感到困惑或 ID所以我倾向于将其命名为 SURROGATE_KEY .我所有其他表都使用
这个问题在这里已经有了答案: How can I get hardware ids/serial numbers through command prompt? (1 个回答) 关闭 9 年前。 我
我想用 C# 做一点许可证管理。 使用普通 PC 镜像,我设置了一些没有序列号的工作站,然后我想使用 C# 守护程序更改序列号。 我的问题:如何使用 C# 更改序列号并激活 Windows 7? 谢谢
我是一名优秀的程序员,十分优秀!