C 獲取常用硬體資訊

2021-06-09 12:45:30 字數 1046 閱讀 2041

/// /// 獲取硬碟序列號

///

///

public static string getdiskserialnum()

return result;

}

/// /// 取得網絡卡的mac位址

///

public static ilistgetnetcardmacaddress()

return str;

}

/// /// 獲取本機ipv4位址

///

///

public static string getlocalip()}}

return strip;

}

/// /// 獲取本機所有ip位址

///

///

public static listgetlocalallip() } return localallip; }
//根據遠端ip位址獲取該ip的mac位址

[dllimport("iphlpapi.dll")]

private static extern int sendarp(int32 dest, int32 host, ref int64 mac, ref int32 length);

[dllimport("ws2_32.dll")]

private static extern int32 inet_addr(string ip); //該函式只能取ipv4

/// /// 獲取遠端mac

///

///

///

public static string getremotemac(string remoteip)

catch (exception err)

}

c 獲取硬體資訊

using system using system.runtime.interopservices using system.management namespace hardware 取cpu編號 public string getcpuid return strcpuid catch end m...

c 獲取硬體資訊

using system using system.runtime.interopservices using system.management namespace hardware 取cpu編號 public string getcpuid return strcpuid catch end m...

C 獲取硬體資訊

using system using system.net using system.runtime.interopservices using system.management 需要在解決方案中引用system.management.dll檔案 獲取機器名 public string getho...