[an error occurred while processing this directive]
One of the most
commonly asked questions on the Windows CE/PocketPC forums and newsgroups
these days is about the Compaq iPaq and its serial number feature.
As you probably
know, every iPaq in existence has its own unique serial number. That means
that, for example, if a developer were to couple an installation of
his/her software with a particular iPaq serial number, that software would
not work on any other iPaqs.
unique serial number also makes it possible to integrate the iPaqs into an
existing corporate (software-based) asset management system.
So far, so good, right? Wrong.
Compaq didn't tell the developers how to read this serial number from
within their own programs. In other words, it's there, and you can use it,
but only if you happen to work for a small computer concern located in the
general Dallas area known as Compaq.
However, all is not lost. It turns out that there are actually two different ways for you as a developer to read this information for yourself!
I've collected a
bit of sample code from two very generous individuals who did the research
for these solutions themselves and were then good enough to post the
solutions on one or another forums. I'll
give a short explanation of each below, but for the most part, if you have
the code and comments, it should be self-explanatory.
Of course, you may
wonder why there are two solutions to begin with; after all, one solution
would be plenty. It turns out that the first solution we'll look at works
very well on the iPaq 1550s and the iPaq 36xx devices with the new ROM,
but not so well on the 36xx series with the old ROM. Similarly, the second
solution should work on all iPaq devices but it a bit of a hack.
Let's take a look
at each of these solutions...
The first solution
is the simpler and more straightforward approach. It uses a
semi-undocumented function called KernelIoControl(),
which allows you to query the system for certain "low-level"
data. In this example, we'll pass a 64-byte TCHAR array into the
function, along with a predefined constant that tells the system we're
looking for a serial number (also known as a UUID, or universally unique
identifier). [Listing 1, below.]
solution is a little bit trickier. It turns out that there is a program in
the \Windows directory of the
iPaq called CreateAssetFile.exe.
When you run this program, it creates a binary file called cpqAssetData.dat
which contains all of the useful information the device has to offer.
(This is how the Asset Viewer control panel applet seems to get its data,
incidentally.) So, by parsing the .DAT file, we too can have access to
all of this useful data.[Listing 2, below.]
All of this is immediately visible from the code listings below and the sample project provided along with this article. Hopefully, this will be helpful and save some time for those of us who are just now discovering a use for the iPaq's serial number feature.
/*Solution generously provided on http://www.PocketProjects.com by "Nusorn" at firstname.lastname@example.org */
#define IOCTL_HAL_GET_UUID CTL_CODE(FILE_DEVICE_HAL, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
unsigned long Len;
Click here for Advertising Information