• 机器码的获取


    首先在添加引用中选中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++中四大强制类型转换!
    队列(queue)的实现
    栈(stack)的实现
    单向链表
    十种排序算法详解及C++实现
    extern “C”
    C语言内存分配及各种数据存储位置
    Python中的classmethod与staticmethod
    关于ORM,以及Python中SQLAlchemy的sessionmaker,scoped_session
    Python中的SQLAlchemy
  • 原文地址:https://www.cnblogs.com/nocanstillbb/p/10608280.html
Copyright © 2020-2023  润新知