我开发的C#库,使用这3个变量确定单声道硬盘序列号?
生成一个唯一的硬件ID- 机器名
- MAC地址
- 硬盘序列号
我能得到在.NET和Mono中的机器名称和MAC地址,但我只能在.NET中获得硬盘序列号。有谁知道是否有任何可能的方式获得单声道的硬盘序列号或应该只使用另一个变量(即:CPU名称,主板ID等)?
我开发的C#库,使用这3个变量确定单声道硬盘序列号?
生成一个唯一的硬件ID我能得到在.NET和Mono中的机器名称和MAC地址,但我只能在.NET中获得硬盘序列号。有谁知道是否有任何可能的方式获得单声道的硬盘序列号或应该只使用另一个变量(即:CPU名称,主板ID等)?
的Mac OS X不支持从用户级应用
获得硬盘序列号如果需求是在Mac根本不是问题您(或您跳过Mac版),我要解决的问题一个畜生道:
使用this article或this问题,你可以判断:
如果你知道你是在Linux系统上,你可以得到的hardrive串行通过running这样system command运行单声道或.NET
/sbin/udevadm info --query=property --name=sda
在mac上,您可以使用Disk Utility(以root身份)获取硬盘序列号。在Windows上,您可以使用标准方法。
谢谢!我可能必须恢复到MAC OSX的唯一标识符原因的不同变量。 – ub3rst4r 2012-02-27 05:36:44
你可以得到它也与名为ioreg
从shell用户权限:
名为ioreg -p IOService的-n AppleAHCIDiskDriver -r | grep的\ “序列号\” | awk的“{$打印NF ;}”
编程:
uint GetVolumeSerial(string rootPathName)
{
uint volumeSerialNumber = 0;
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "/usr/sbin/ioreg";
psi.UseShellExecute = false;
psi.Arguments = "-p IOService -n AppleAHCIDiskDriver -r -d 1";
psi.RedirectStandardOutput = true;
Process p = Process.Start(psi);
string output;
do
{
output = p.StandardOutput.ReadLine();
int idx = output.IndexOf("Serial Number");
if (idx != -1)
{
int last = output.LastIndexOf('"');
int first = output.LastIndexOf('"', last - 1);
string tmp = output.Substring(first + 1, last - first - 1);
volumeSerialNumber = UInt32.Parse(tmp);
break;
}
} while (!p.StandardOutput.EndOfStream);
p.WaitForExit();
p.Close();
return volumeSerialNumber;
}
注意的是,机器名和MAC地址可以手动进行设置,因此他们不是真正独一无二的。 – 2012-02-27 00:51:52
GUID基于MAC地址... – ub3rst4r 2012-02-27 07:08:10
而MAC地址可能被欺骗:http://osxdaily.com/2008/01/17/how-to-spoof-your-mac-address-in-mac -os-x /您不能认为它对于特定计算机上的特定以太网接口是唯一的。 – 2012-02-27 12:40:15