Solved

Get serial number different for PPC2003 than WM5/5

Posted on 2009-07-01
2
548 Views
Last Modified: 2013-12-27
I use the following code to get the serial number for my WM5/6 devices:

typedef int (__cdecl *MYPROC)(LPBYTE, DWORD, DWORD, LPBYTE, DWORD *);

MYPROC ProcAdd;

// Attemp to load aygshell.dll
HMODULE hLib = LoadLibrary(_T("coredll.dll"));
if (hLib)
{            
      ProcAdd = (MYPROC)GetProcAddress(hLib, _T("GetDeviceUniqueID"));

      if(ProcAdd)
      {

                   HRESULT hr = NOERROR;      
                    const GUID     bApplicationData1  = { 0x8d552bd1, 0xe232, 0x4107, { 0xb7,  
                             0x2d, 0x38, 0xb6, 0xa4, 0x72, 0x64, 0x39 } };
               const DWORD    cbApplicationData1 = sizeof (bApplicationData1);

       // Buffers to hold the two device IDs we are going to generate
      BYTE                g_bDeviceID1[GETDEVICEUNIQUEID_V1_OUTPUT];
      // Lengths of the returned device IDs
      DWORD               g_cbDeviceID1;

      g_cbDeviceID1 = GETDEVICEUNIQUEID_V1_OUTPUT;
      hr = ProcAdd (reinterpret_cast<LPBYTE>(const_cast<LPGUID>
                            &bApplicationData1)), cbApplicationData1,GETDEVICEUNIQUEID_V1,
                                 g_bDeviceID1,
                                 &g_cbDeviceID1);

      TCHAR        szDeviceID[(GETDEVICEUNIQUEID_V1_OUTPUT * 2) + 1];
            
      if (SUCCEEDED (DeviceID2String (g_bDeviceID1, g_cbDeviceID1, szDeviceID,
                                                                                                    ARRAYSIZE (szDeviceID))))
      {
            sSerialNo = szDeviceID;
      }
                  
}
else
{
      AfxMessageBox(_T("GetSerialNumber Error: ProcAdd NULL"));
      sSerialNo.Empty();

}

CloseHandle(hLib);

This works fine in WM5/6 but in PPC2003 it fails here:
ProcAdd = (MYPROC)GetProcAddress(hLib, _T("GetDeviceUniqueID"));
if(ProcAdd)
{
    blah blah
}

Why is this and how can I go about it?

Thanks
0
Comment
Question by:Wanting2LearnMan
  • 2
2 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 24760380
You can retrieve the same data by using KernelIOControl API with IOCTL_HAL_GET_DEVICEID. PPC2003 does have the privilliged mode, so it is possible to call such API without any problem:
http://msdn.microsoft.com/en-us/library/aa446562.aspx
http://msdn.microsoft.com/en-us/library/ms880643.aspx
 http://forum.soft32.com/pda/device-id-unique-device-ftopict53543.html
 Other tricks about the subject:
1. GetDeviceCaps - you can retrieve OEM info and use it.
2. Phone number or IMEI if it is phone enabled PDA.
3. You can retrieve the serial number of the SD-card.
4. You can generate yourself a unique number and save on a persistent storage.
 
0
 
LVL 33

Assisted Solution

by:pgnatyuk
pgnatyuk earned 500 total points
ID: 24784132
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now