惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog
腾讯CDC
L
LangChain Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
量子位
Apple Machine Learning Research
Apple Machine Learning Research
Cloudbric
Cloudbric
B
Blog RSS Feed
B
Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
S
Schneier on Security
Project Zero
Project Zero
宝玉的分享
宝玉的分享
美团技术团队
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
T
Threatpost
A
Arctic Wolf
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
Recorded Future
Recorded Future
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
SecWiki News
SecWiki News
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
C
Check Point Blog
L
Lohrmann on Cybersecurity
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
Martin Fowler
Martin Fowler

博客园 - 锐

Windows7 Server 2008 下安装Oracle 10g提示“程序异常终止,发生未知错误”的解决方法 Android应用自动更新功能的代码实现 Undefined exploded archive location 项目不能部署 linux下mysql5.5.19编译安装笔记【已验证】 CSS+DIV排版时容器内对象全部设置了float属性后容器不能自动适应高度的解决方案 php Smarty模板生成html文档的方法 - 锐 - 博客园 如何解决Firefox检测不到div高度问题 DD_belatedPNG,解决IE6不支持PNG绝佳方案 .net程序运行在无.net framework环境中 struts2 freemarker当中引进java 常量java静态方法 - 锐 简体-繁体互转换的一个JS - 锐 - 博客园 C#实现通过URL触发自己的程序 Tencent://Message/协议的实现原理 - 锐 - 博客园 国内三大免费流媒体WAP门户网站(视频类WAP网站) C#中RSA加密解密和签名与验证的实现 (转) Struts2.1.6使用小技巧 java -D参数简化加入多个jar MySQL Proxy 学习笔记(转) 用apache ab做web压力测试
C#读取CPUid,硬盘id,网卡Mac地址
· 2010-07-11 · via 博客园 - 锐

代码

    using System;
    
using System.Collections.Generic;
    
using System.Linq;
    
using System.Management;
    
using System.Runtime.InteropServices;
    
using System.Text;namespace cai
    {
        
        
class HardwareInfo
        {
            
/// <summary>
            
/// 取机器名 
            
/// </summary>
            
/// <returns></returns>
            public string GetHostName()
            {
                
return System.Net.Dns.GetHostName();
            }
               
            
/// <summary>
            
/// 取CPU编号 
            
/// </summary>
            
/// <returns></returns>
            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 "";
                }
            }
            
/// <summary>
            
/// 读取Mac地址
            
/// </summary>
            
/// <returns></returns>
            public string GetNetCardMacAddress()
            {
                ManagementClass mc;
                ManagementObjectCollection moc;
                mc 
= new ManagementClass("Win32_NetworkAdapterConfiguration");
                moc 
= mc.GetInstances();
                
string str = "";
                
foreach (ManagementObject mo in moc)
                {
                    
if ((bool)mo["IPEnabled"== true)
                        str 
= mo["MacAddress"].ToString();

                }

return str;
            }
           
/// <summary>
            
/// 读取C盘序列号
           
/// </summary>
           
/// <returns></returns>
            public string GetDiskVolumeSerialNumber()
            {
                ManagementObject disk;
                disk 
= new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
                disk.Get();
                
return disk.GetPropertyValue("VolumeSerialNumber").ToString();
            }
        }
    }

从网络收集整理出来。。