zoukankan      html  css  js  c++  java
  • 机器码的获取

    首先在添加引用中选中System.Management
    再在开始部门:
    using System.Management;
    using System.Management.Instrumentation;
    
    private void GetInfo() 
    { 
    string cpuInfo = "";//cpu序列号 
    ManagementClass cimobject = new ManagementClass("Win32_Processor"); 
    ManagementObjectCollection moc = cimobject.GetInstances(); 
    foreach(ManagementObject mo in moc) 
    { 
    cpuInfo = mo.Properties["ProcessorId"].Value.ToString(); 
    Response.Write ("cpu序列号:"+cpuInfo.ToString ()); 
    }
    
    //获取硬盘ID 
    String HDid; 
    ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"); 
    ManagementObjectCollection moc1 = cimobject1.GetInstances(); 
    foreach(ManagementObject mo in moc1) 
    { 
    HDid = (string)mo.Properties["Model"].Value; 
    Response.Write ("硬盘序列号:"+HDid.ToString ()); 
    }
    
    
    //获取网卡硬件地址
    
    
    
    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 
    ManagementObjectCollection moc2 = mc.GetInstances(); 
    foreach(ManagementObject mo in moc2) 
    { 
    if((bool)mo["IPEnabled"] == true) 
    Response.Write("MAC address	{0}"+mo["MacAddress"].ToString()); 
    mo.Dispose(); 
    } 
    }
    
    在添加引用中选中System.Management
    再在开始部门:
    using System.Management;
    using System.Management.Instrumentation;
    
    private void GetInfo() 
    { 
    string cpuInfo = "";//cpu序列号 
    ManagementClass cimobject = new ManagementClass("Win32_Processor"); 
    ManagementObjectCollection moc = cimobject.GetInstances(); 
    foreach(ManagementObject mo in moc) 
    { 
    cpuInfo = mo.Properties["ProcessorId"].Value.ToString(); 
    Response.Write ("cpu序列号:"+cpuInfo.ToString ()); 
    }
    
    //获取硬盘ID 
    String HDid; 
    ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"); 
    ManagementObjectCollection moc1 = cimobject1.GetInstances(); 
    foreach(ManagementObject mo in moc1) 
    { 
    HDid = (string)mo.Properties["Model"].Value; 
    Response.Write ("硬盘序列号:"+HDid.ToString ()); 
    }
    
    
    //获取网卡硬件地址
    
    
    
    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); 
    ManagementObjectCollection moc2 = mc.GetInstances(); 
    foreach(ManagementObject mo in moc2) 
    { 
    if((bool)mo["IPEnabled"] == true) 
    Response.Write("MAC address	{0}"+mo["MacAddress"].ToString()); 
    mo.Dispose(); 
    } 
    }
  • 相关阅读:
    【C语言天天练(二二)】位操作
    远程调用内核接口的封装类(RCKObjs)
    03010_防止SQL注入
    PHP 5 SimpleXML 函数
    PHP 5 String 函数
    PHP 5 MySQLi 函数
    PHP 杂项 函数
    PHP PDO
    PHP 5 时区
    分享海量 iOS 及 Mac 开源项目和学习资料
  • 原文地址:https://www.cnblogs.com/nocanstillbb/p/10608280.html
Copyright © 2011-2022 走看看