Solved

Get serial number different for PPC2003 than WM5/5

Posted on 2009-07-01
2
559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Let me explain this picture a little bit.  First, in case you haven't already guessed, you are looking at my 2 phones, an Android Samsung Galaxy S5 on the left and an iPhone 5 on the right.  They are on their respective cradles on my desk.  But, you…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

635 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