can*_*rso 5

您不能按照说法检索MAC地址,但如果您正在尝试执行此操作,则可以检索硬件特定信息以识别计算机.

这是一篇完整的msdn文章讨论主题:使用应用程序特定硬件ID(ASHWID)实现每个设备应用程序逻辑的指南(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);
Run Code Online (Sandbox Code Playgroud)