public void GetMacAddress()
{
string qry = "select * FROM Win32_NetworkAdapter";
System.Management.ObjectQuery objectQuery = new System.Management.ObjectQuery(qry);
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(objectQuery);
string macAdd = "";
foreach (System.Management.ManagementObject nicObj in searcher.Get())
{
macAdd = nicObj["MACAddress"].ToString();
MessageBox.Show(macAdd);
}
}
public void GetMacAddress2()
{
string queryString = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled= 'TRUE'";
System.Management.ManagementObjectSearcher query = new System.Management.ManagementObjectSearcher(queryString);
System.Management.ManagementObjectCollection queryCol = query.Get();
foreach (System.Management.ManagementObject mo in queryCol)
{
string[] address = (string[])mo["IPAddress"];
string[] subnets = (string[])mo["IPSubnet"];
}
}
private String GetMACAddress()
{
String strMACAddress = String.Empty;
if (GetNetConnectionStatus())
{
ObjectQuery objQuery = new ObjectQuery("SELECT NetConnectionStatus, MacAddress FROM Win32_NetworkAdapter");
ManagementObjectSearcher mobjSearcher = new ManagementObjectSearcher(objQuery);
try
{
foreach (ManagementObject obj in mobjSearcher.Get())
{
if (obj["NetConnectionStatus"] != null)
{
if (Convert.ToInt32(obj["NetConnectionStatus"].ToString()) == 2)
{
strMACAddress = obj["MACAddress"].ToString();
break;
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
strMACAddress = String.Empty;
}
}
return strMACAddress;
}
Connection strings for Informix (0) | 2009.08.14 |
---|---|
Visual C#.NET을 사용하여 XML 파일에 특수 문자 사용 (0) | 2009.08.12 |
HDD Serial (0) | 2009.05.25 |
CPU Serial (0) | 2009.05.25 |
DataSet 압축 (0) | 2009.04.03 |