WINCE.NET/WINDOWS MOBILE PDA 제품의 MAC Address 구하는 함수입니다.
[System.Runtime.InteropServices.DllImport("iphlpapi.dll", SetLastError = true)]
private static extern int GetAdaptersInfo(byte[] info, ref uint size);
/// <summary>
/// Gets the Mac Address
/// </summary>
/// <returns>the mac address or ""</returns>
public string GetMacAddress()
{
uint num = 0u;
GetAdaptersInfo(null, ref num);
byte[] array = new byte[(int)((UIntPtr)num)];
int adaptersInfo = GetAdaptersInfo(array, ref num);
if (adaptersInfo == 0)
{
string macAddress = "";
int macLength = BitConverter.ToInt32(array, 400);
macAddress = BitConverter.ToString(array, 404, macLength);
macAddress = macAddress.Replace("-", ":");
return macAddress;
}
else
return "";
}
'C#' 카테고리의 다른 글
[C#/PDA]SQLite Sample Source 및 SQLite Browser utility (0) | 2016.02.19 |
---|---|
[C#]NativeWifi를 이용한 무선랜 정보 얻어오기 예제 (0) | 2016.02.17 |
[C#/PDA]Windows Mobile 6 Professional SDK (0) | 2016.02.16 |
Zebra Barcode Command(ZPL) (0) | 2016.02.16 |
[C#/PDA]무선랜 감도 확인 예제 (0) | 2016.02.16 |