DeviceID not unique

Last post 03-31-2011 3:46 by Rostock. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-23-2005 21:35

    DeviceID not unique

    Hi all,

    From what I have read, the GetDeviceID value is always meant to be unique. I have two devices from the same manufacturer and they are returning identical device ids - which ruins my plans for identifying them remotely.

    Am I correct that the this id is meant to be device specific and not model specific. If am am wrong, are there any alternatives?

    Thanks.
  • 03-30-2005 16:18 In reply to

    Re: DeviceID not unique

    The problem with the current code is that the PresetID portion of the ID can be more than 10 bytes on newer devices, and since our code only returns the first 10 bytes they will most likely be the same on the same model of device. I'll change this to always take the last 10 bytes of the PresetID (on many new devices this is 14 bytes) so it should always give unique IDs between devices in the same model.

    Peter

    Peter Foot
    Windows Embedded MVP
    www.inthehand.com | www.opennetcf.org
  • 03-31-2005 9:12 In reply to

    Re: DeviceID not unique

    I am pretty sure that Peter has now corrected this issue with the DeviceID being unique.

    The source for this is in the Source Vault.

    Justin Heasman
    Software Development Manager
    Office Mobile Solutions Ltd.
  • 06-07-2005 1:12 In reply to

    Re: DeviceID not unique

    Hi
    I've found this comment about KernelIoControl over internet:


    "Unfortunately, the mechanism is broken on some older devices. In fact, on these older devices, if you claim the size of the buffer is anything other than 16 bytes (the size of a GUID), the method fails and gives you nothing. Do not despair! Passing in 16 as the size of the buffer will return you the entire 16 byte Device ID in the buffer, which you can then use as returned."


    My question is -> is that TRUE?
    If it is true - may be source must include solution for this problem

    Greetings from Kostadin
  • 08-01-2005 9:27 In reply to

    • StuMak
    • Top 100 Contributor
    • Joined on 09-05-2007
    • Posts 6

    Re: DeviceID not unique

    I have downloaded file Core.cs version 11 from Vault but I have got the old version. So I wonder if it is possible to have a compiled version of the particular DLL instead of the source.

    Thanks in advance,
    Stavros Makridis.

    quote:
    Originally posted by peterfoot

    The problem with the current code is that the PresetID portion of the ID can be more than 10 bytes on newer devices, and since our code only returns the first 10 bytes they will most likely be the same on the same model of device. I'll change this to always take the last 10 bytes of the PresetID (on many new devices this is 14 bytes) so it should always give unique IDs between devices in the same model.

    Peter

    Peter Foot
    Windows Embedded MVP
    www.inthehand.com | www.opennetcf.org

  • 03-31-2011 3:46 In reply to

    Re: DeviceID not unique

    Here is an example of how to implement this:

    class DeviceId
    {    
        [DllImport("coredll.dll")]
        private extern static int GetDeviceUniqueID([In, Out] byte[] appdata,
                                                    int cbApplictionData,
                                                    int dwDeviceIDVersion,
                                                    [In, Out] byte[] deviceIDOuput,
                                                    out uint pcbDeviceIDOutput);
        

        /// <summary>
        /// Gets the unique Device ID.
        /// </summary>
        /// <returns></returns>
        public static string GetDeviceID()
        {
            string appString = "MyApplication";
            byte[] appData = new byte[appString.Length];
            for(int count = 0; count < appString.Length; count++)
            {
                appData[count] = (byte)appString[count];
            }
        
            int appDataSize = appData.Length;
            byte[] DeviceOutput = new byte[20];
            uint SizeOut = 20;
            GetDeviceUniqueID(appData, appDataSize, 1, DeviceOutput, out SizeOut);
        
            string idString = "";
            for(int i = 0; i < DeviceOutput.Length; i++)
            {
                if(i == 4 || i == 6 || i == 8 || i == 10)
                    idString = String.Format("{0}-{1}", idString, DeviceOutput[i].ToString("x2"));
                else
                    idString = String.Format("{0}{1}", idString, DeviceOutput[i].ToString("x2"));
            }
            return idString;
        }    
    }    

Page 1 of 1 (6 items)