- 最後登錄
- 2022-11-12
- 在線時間
- 0 小時
- 註冊時間
- 2015-1-2
- 閱讀權限
- 10
- 精華
- 0
- UID
- 861364
- 帖子
- 0
- 積分
- 0 點
- 潛水值
- 7650 米
| 所有積分大於負-100的壞孩子,將可獲得重新機會成為懲罰生,權限跟幼兒生一樣。 本帖最後由 arthurliuliu 於 2009-12-25 12:08 PM 編輯
參考看看吧!
- using System.Net.NetworkInformation;
- private void GetMACaddress()
- {
- int n = 0;
- int index = 0;
- NetworkInterface[] m_pNics = NetworkInterface.GetAllNetworkInterfaces();
- NetworkInterface m_pAdapter = null;
- try
- {
- for (index = 0; index < m_pNics.Length; index++)
- {
- m_pAdapter = (NetworkInterface)m_pNics.GetValue(index);
- if(m_pAdapter.Description.Contains("網卡的辨別名稱"))
- {
- IPInterfaceProperties m_pAdapterProperties = m_pAdapter.GetIPProperties();
- // Print MAC address
- string macaddr = m_pAdapter.GetPhysicalAddress().ToString();
- string strMac = macaddr.Substring(0, 2);
- for (n = 0; n < 5; n++)
- strMac += ":" + macaddr.Substring(2 * n + 2, 2);
- //strMac is MAC address
- m_pAdapterProperties = null;
- }
- else
- {
- }
- m_pAdapter = null;
- } //for (index = 0; index < m_pNics.Length; index++)
- m_pNics = null;
- }
- catch (Exception)
- {
- m_pNics = null;
- m_pAdapter = null;
- }
- }
複製代碼 ... |
|