How do I get a Unique Identifier for a Device within Windows 10 Universal?

后端 未结 5 762
盖世英雄少女心
盖世英雄少女心 2020-11-29 09:33

This is my old implementation to get a Unique DeviceID for Windows Universal 8.1 but the type HardwareIdentification does not exist anymore.

    private sta         


        
5条回答
  •  無奈伤痛
    2020-11-29 09:59

    //you can use this
    //its working with me very fine on windows 10
    //replace the word bios with any hardware name you want
    //data also can be found with using windows application named (wbemtest) 
    
    using System.Management;
    public static async Task ReturnHardWareID()
            {
                string s = "";
                Task task = Task.Run(() =>
                {
                    ManagementObjectSearcher bios = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
                    ManagementObjectCollection bios_Collection = bios.Get();
                    foreach (ManagementObject obj in bios_Collection)
                    {
                        s = obj["SerialNumber"].ToString();
                        break; //break just to get the first found object data only
                    }
                });
                Task.WaitAll(task);
    
                return await Task.FromResult(s);
            }
    

提交回复
热议问题