0
我需要獲取Windows Mobile設備的MAC address。是否有可能不使用OpenNetCF,而只使用.NET Compact Framework?解決方案使用C#(Visual Studio 2008,智能設備項目)。從網絡適配器讀取MAC地址
看了Read MAC Address from network adapter in .NET,我希望通過底座使用的例子,但有在該設備上沒有KERNEL32.DLL。
有aother方式.NET Compact Framework中獲得的MAC地址,或者我怎麼能取代以下方法:
[DllImport("Kernel32.dll", EntryPoint = "CopyMemory")]
private static extern void ByteArray_To_IPAdapterInfo(ref AdapterInfo dst, Byte[] src, int size);
[DllImport("Kernel32.dll", EntryPoint = "CopyMemory")]
private static extern void IntPtr_To_IPAdapterInfo(ref AdapterInfo dst, IntPtr src, int size);
但是,我應該如何將接收到的字節數組轉換爲結構數組?或者我應該如何從字節數組中提取每個結構? – horgh 2012-07-08 16:16:27
在前面提到的問題中,plinth使用了kernel32.dll(IntPtr_To_IPAdapterInfo,ByteArray_To_IPAdapterInfo)中的方法。但是kernel32.dll在windows mobile上不可用(不是嗎?)。 – horgh 2012-07-08 16:18:19
我使用不安全的代碼解析了SDF代碼中的字節數組,因爲它似乎是最快的方法。您可以輕鬆地創建一個sruct並根據成員設置變量。如果你想要的只是MAC,你實際上可以從結果數組中以適當的偏移量複製到地址字節的本地數組中。 – ctacke 2012-07-08 23:04:24