C# 如何用c语言为windows mobile 6.0设备编程获取MAC地址
如何用c语言编程获取windows mobile 6.0设备的MAC地址?Net compatc framework 3.5不支持System.Net.NetworkInformation。我们可以在此类问题中使用MDSDK,如C# 如何用c语言为windows mobile 6.0设备编程获取MAC地址,c#,.net,windows-mobile,mac-address,C#,.net,Windows Mobile,Mac Address,如何用c语言编程获取windows mobile 6.0设备的MAC地址?Net compatc framework 3.5不支持System.Net.NetworkInformation。我们可以在此类问题中使用MDSDK,如 using PsionTeklogix.Peripherals; namespace EnumAdapters { public partial class Form1 : Form { public Form1() {
using PsionTeklogix.Peripherals;
namespace EnumAdapters
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ArrayList pList = null;
string[] lStatistic = null;
try
{
pList = Peripherals.EnumerateAdapters();
}
catch (Exception ex)
{
MessageBox.Show("failed with\r\n" + ex.Message, "EnumerateAdapters()");
Close();
return;
}
listBox1.Items.Clear();
foreach (string AdapterName in pList)
{
try
{
listBox1.Items.Add(AdapterName + (Peripherals.IsAdapterPresent(AdapterName) ? " is present" : " is NOT present") + (Peripherals.IsWirelessAdapter(AdapterName) ? " [wireless adapter] " : ""));
lStatistic = Peripherals.GetAdapterStatistics(AdapterName); // See Note 1
foreach (string StatInfo in lStatistic)
{
if (StatInfo.StartsWith("Local MAC Address"))
{
listBox1.Items.Add("» " + StatInfo);
break;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Close();
return;
}
}
}
}
}
我知道这已经有一段时间了,但我需要这个,我发现我可以使用上面代码的OpenNETCF版本,但需要做一些调整:
INetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//for each j you can get the MAC
PhysicalAddress address = nics[0].GetPhysicalAddress();
byte[] bytes = address.GetAddressBytes();
for(int i = 0; i < bytes.Length; i++) {
// Display the physical address in hexadecimal.
Console.Write("{0}", bytes[i].ToString("X2"));
// Insert a hyphen after each byte, unless we are at the end of the address.
if(i != bytes.Length - 1) {
Console.Write("-");
}
}
INetworkInterface[]nics=NetworkInterface.getAllNetworkInterface();
//对于每个j,你都可以得到MAC
PhysicalAddress地址=NIC[0]。GetPhysicalAddress();
字节[]字节=地址。GetAddressBytes();
for(int i=0;i
这使用特定于设备的库,因此仅适用于Psion设备。