C 獲取本機的MAC位址

2021-04-18 02:58:33 字數 1007 閱讀 5238

using system; using system.collections.generic;

using system.componentmodel;

using system.data; using system.drawing;

using system.text;

using system.windows.forms;

using system.net;

using system.management;

using system.net.sockets; using system.collections; //using system.componentmodel;using system.windows.forms;using system.data;        

namespace test                                             managementclass mc;          

mc=new managementclass("win32_networkadapterconfiguration");                        managementobjectcollection moc=mc.getinstances();                      

foreach(managementobject mo in moc)                     

if(mo["ipenabled"].tostring()=="true")                     

mac=mo["macaddress"].tostring();          

this.text+=hostinfo;         

this.text+=s;       

this.text+=mac;      

//  button1.enabled=false;            button2.focus();  

C 獲取本機MAC位址

static void main string args private static string getmac moc null mc null return mac catch 另外,需要說明的就是乙個錯誤 問題 在c 程式設計中,已經在程式中已經新增了 using system.manage...

PB獲取本機Mac位址

得到計算機名字 function boolean getcomputernamea ref string lpbuffer,ref ulong nsize library kernel32.dll alias for getcomputernamea ansi 設定計算機名字 function bo...

C 獲取本機IP位址和Mac位址的方法

查詢了幾個方法,經過除錯修改,下面這個方法能很好的獲取到本地的ip和mac位址。可以用於這方面的功能實現。主要是要新增system.management的引用。using system using system.management using system.net public class pro...