I want system id to string .I have used bit converter but not able to match with the current PC seri

Below is my sample code

    var buffer = SystemIdentification.GetSystemIdForPublisher();

    if (buffer != null)
    {
        var id = buffer.Id;


        using (var reader = DataReader.FromBuffer(id))
        {
            var bytes = new byte[id.Length];
            var id = BitConverter.ToString(bytes);
        }

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @Aditkothari You can try to use following link to get the id with string type.

         class AppUtils
    {
        private Guid deviceId;
        private string deviceStr;
        private Guid appId;
        public Guid ApplicationId
        {
            get
            {
                if (this.deviceId == Guid.Empty)
                {
                    EasClientDeviceInformation deviceInformation = new EasClientDeviceInformation();
                    this.deviceId = deviceInformation.Id;
                }
    
    
    
                return this.deviceId;
            }
        }
        public string DeviceId
        {
    
    
    
            get
            {
                if (this.appId == Guid.Empty)
                {
                    SystemIdentificationInfo systemId = SystemIdentification.GetSystemIdForPublisher();
    
    
    
                    // Make sure this device can generate the IDs
                    if (systemId.Source != SystemIdentificationSource.None)
                    {
                        // The Id property has a buffer with the unique ID
                        DataReader dataReader = Windows.Storage.Streams.DataReader.FromBuffer(systemId.Id);
                        deviceStr = dataReader.ReadGuid().ToString();
                    }
                }
    
    
    
                return deviceStr;
            }
        }
    }
    
Sign In or Register to comment.