MS's GetDeviceID() - major problem

  • Thread starter Thread starter Hilton
  • Start date Start date
H

Hilton

Hi,

Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/retrievedeviceid.asp

Usually this code works well. However I have notice 2 problems:

1. PlatformIDSize usually is 6, but can be 8. When it is 8, the code was
throwing an exception since I only allocated 16 bytes (not 18). If I did
"Min (6, PlatforIDSize), then the UUID was reported as
XXXX-XXXX-XXXX-XXXX-1234-1234-XXXX-XXXX; i.e. "1234" (for example) is
reported twice. If I then change the loop from:

for (int i = PlatformIDOffset;
i < PlatformIDOffset + PlatformIDSize;
i ++ )

to:

int diff = Math.Max (0, dwPlatformIDSize - 6);
dwPlatformIDSize = Math.Min (dwPlatformIDSize, 6);

dwPlatformIDOffset += diff;

for (int i = PlatformIDOffset;
i < PlatformIDOffset + PlatformIDSize;
i ++ )
{
...
}

then the UUID reported is the same as the UUID reported by the OS (via the
shipped utility). Does this make sense? MS's code is wrong. but is mine
correct?

2. I've noticed something else. Sometimes (using MS's original code), all
6 bytes are zero; i.e. UUID ends in 0000-0000-0000. This has gotta be
wrong - right? Will my modification fix this? Has anyone seen these zeroes
who can verify it?

I'm seeing these UUID from users and not my own PDAs so it's tougher to
debug.

Thanks!

Hilton
 
Hilton,

My understanding about Device IDs on Pockets PCs is that with the Pocket PC
2002 OS, the DeviceID was optional and installed by OEMs. Therefore, if your
users have this OS there was never any guarantee that there would be a
DeviceID for some brands (OEM) of Pocket PCs. I believe HP iPAQs alway
supplied them but other suppliers may not have.

Further, my understanding is that Windows Mobile 2003 does implement unique
DeviceIDs so you should be able to guarantee a unique number.

Regards,
Neville Lang
 
Neville said:
Hilton,

My understanding about Device IDs on Pockets PCs is that with the Pocket PC
2002 OS, the DeviceID was optional and installed by OEMs. Therefore, if your
users have this OS there was never any guarantee that there would be a
DeviceID for some brands (OEM) of Pocket PCs. I believe HP iPAQs alway
supplied them but other suppliers may not have.

Further, my understanding is that Windows Mobile 2003 does implement unique
DeviceIDs so you should be able to guarantee a unique number.

Neville,

Thanks for the email. The "1234" exampe I provided was running on a Mobile
2003 device; i.e. MS's code does not work on (all) Mobile 2003 devices
without my modification. I didn't mention that - sorry.

I am not sure on what OS the "0000" problem appears (I'll find out), but
that is without my modification. I'll follow up with users to see if the
modification helped.

MS engineers - any ideas?

Thanks,

Hilton
 
Back
Top