windows-8 – 如何以编程方式在WinRT(Windows 8)中获取mac地址?
发布时间:2020-12-13 20:29:25 所属栏目:Windows 来源:网络整理
导读:我在WinRT中寻找一个API来访问mac地址. 您不能按照说法检索MAC地址,但如果您正在尝试执行此操作,则可以检索硬件特定信息以识别计算机. 这是一篇完整的msdn文章,讨论了这个主题:Guidance on using the App Specific Hardware ID (ASHWID) to implement per-d
我在WinRT中寻找一个API来访问mac地址.
您不能按照说法检索MAC地址,但如果您正在尝试执行此操作,则可以检索硬件特定信息以识别计算机.
这是一篇完整的msdn文章,讨论了这个主题:Guidance on using the App Specific Hardware ID (ASHWID) to implement per-device app logic (Windows) 小心只使用您需要的信息而不是完整的ID,因为它可能会根据您无用的信息(例如Dock Station字节)而改变. 这是基于几个字节(CPU ID,内存大小,磁盘设备的序列号和BIOS)的计算设备ID的代码示例: string deviceSerial = string.Empty; // http://msdn.microsoft.com/en-us/library/windows/apps/jj553431 Windows.System.Profile.HardwareToken hardwareToken = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null); using (DataReader dataReader = DataReader.FromBuffer(hardwareToken.Id)) { int offset = 0; while (offset < hardwareToken.Id.Length) { byte[] hardwareEntry = new byte[4]; dataReader.ReadBytes(hardwareEntry); // CPU ID of the processor || Size of the memory || Serial number of the disk device || BIOS if ((hardwareEntry[0] == 1 || hardwareEntry[0] == 2 || hardwareEntry[0] == 3 || hardwareEntry[0] == 9) && hardwareEntry[1] == 0) { if (!string.IsNullOrEmpty(deviceSerial)) { deviceSerial += "|"; } deviceSerial += string.Format("{0}.{1}",hardwareEntry[2],hardwareEntry[3]); } offset += 4; } } Debug.WriteLine("deviceSerial=" + deviceSerial); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Windows下编译PHP5.4和xdebug全记录
- for-loop – 单行语句:%% i’意外在这个时候’
- .NET Core,Windows Nano Server和System.Managem
- 在绑定到Image.Source时,Xaml如何创建字符串到Bi
- x86 assember – Windows下的非法操作码0xff / 7
- windows-server-2008 – 返回HTTP 503的Microsof
- 通过console.log()打印window对象的属性、方法、
- CreateThread()在64位Windows上失败,在32位Windo
- windows-7 – RDP与Windows 7的连接速度非常慢
- windows – Delphi2010中的CoInternetIsFeatureE
热点阅读