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(); 
    } 
    }
  • 相关阅读:
    final .....finally ...... 和Finalize ......区别
    MyEclipse中常用的快捷键大全,快来.....
    简单的描述Java中的构造函数,及访问修饰符
    分层开发---酒店管理系统---
    C#深入.NET平台的软件系统分层开发
    影院售票系统-----一个让你有成就感的小项目,只有一丢丢哦
    mysql数据库进阶
    MySQL练习
    MySQL中常见函数
    TCP协议之三次握手四次挥手
  • 原文地址:https://www.cnblogs.com/nocanstillbb/p/10608280.html
Copyright © 2011-2022 走看看