2.Using WMI
Win32 NetworkAdapterConfiguration Data Fields:
DefaultIPGateway
An array of IP router addresses assigned to the device
Description
The description of the network device
DHCPEnabled
Whether the device dynamically assigns its IP address
DHCPServer
The DHCP server used to assign an IP address
DNSHostName
The DNS host that is used for resolving hostnames
IPAddress
An array of IP addresses assigned to the device
IPEnabled
Whether the device uses IP on the network
IPSubnet
An array of IP subnet addresses used on the device
MACAddress
The Ethernet MAC address assigned to the network device
--------------------------------------------------------------------
1 Create a ManagementObjectSearcher object that contains a SQL Select statement for the
补充两种办法:1 Using Registry. 2 Using WMI
1 Using Registry
Microsoft.Win32.Registry--包含注册表的基础键值名称:Current_User, Local_Machine, Classes_Root, Current_Config, Dyn_Data, and Users.你必须使用其中之一。
Microsoft.Win32.RegistryKey--包含操作(查询,修改注册表键值或者数据)的Class和Method。
CardGrab.cs program
-------------------------------
using System;
using Microsoft.Win32;
class CardGrab
{
public static void Main ()
{
RegistryKey start = Registry.LocalMachine;
//你必须定义一个Root Key。