点击(此处)折叠或打开
- using System;
-
- using System.Runtime.InteropServices;
-
- using System.Management;
-
- namespace Hardware
-
- {
-
- /// summary
-
- /// Hardware_Mac 的摘要说明。
-
- /// /summary
-
- public class HardwareInfo
-
- {
-
- //取机器名
-
- public string GetHostName()
-
- {
-
- return System.Net.Dns.GetHostName();
-
- }
-
- //取CPU编号
-
- public String GetCpuID()
-
- {
-
- try
-
- {
-
- ManagementClass mc = new ManagementClass(Win32_Processor);
-
- ManagementObjectCollection moc = mc.GetInstances();
-
- String strCpuID = null;
-
- foreach (ManagementObject mo in moc)
-
- {
-
- strCpuID = mo.Properties[ProcessorId].Value.ToString();
-
- break;
-
- }
-
- return strCpuID;
-
- }
-
- catch
-
- {
-
- return ;
-
- }
-
- }//end method
-
- //取第一块硬盘编号
-
- public String GetHardDiskID()
-
- {
-
- try
-
- {
-
- ManagementObjectSearcher searcher =
-
- new ManagementObjectSearcher(SELECT * FROM Win32_PhysicalMedia);
-
- String strHardDiskID = null;
-
- foreach (ManagementObject mo in searcher.Get())
-
- {
-
- strHardDiskID = mo[SerialNumber].ToString().Trim();
-
- break;
-
- }
-
- return strHardDiskID
以上就是获取计算机信息的类,在VS中建一个类,然后生成DLL就可以在平台中使用了
原文地址:http://bbs.delit.cn/thread-584-1-1.htmlhttp://
转载请注明出处:
撰写人:度量科技www.delit.cn
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/328153/viewspace-1973738/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/328153/viewspace-1973738/