Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get serial number different for PPC2003 than WM5/5

Posted on 2009-07-01
2
Medium Priority
?
568 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 2000 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 2000 total points
ID: 24784132
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.
Suggested Courses

782 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