Solved

Reading Serial number from PDA with eVB 3.0 ?

Posted on 2004-08-09
1
820 Views
Last Modified: 2008-02-01
I am trying to get the serial number from my PDA (iPaq 3800) so I can hard code it in to my program so it will only run with my PDA.

I have obtained some code, but I don't know how to implement it in to my application in eVB 3.0.

Here is the code:

#include <WINIOCTL.H>

extern "C" __declspec(dllimport)
BOOL KernelIoControl(
  DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize,
  LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned
);

#define IOCTL_HAL_GET_DEVICEID CTL_CODE(FILE_DEVICE_HAL, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)

CString GetSerialNumberFromKernelIoControl()
{
      DWORD dwOutBytes;
      const int nBuffSize = 4096;
      byte arrOutBuff[nBuffSize];

      BOOL bRes = ::KernelIoControl(IOCTL_HAL_GET_DEVICEID,
                                     0, 0, arrOutBuff, nBuffSize, &dwOutBytes);

      if (bRes) {
            CString strDeviceInfo;
            for (unsigned int i = 0; i<dwOutBytes; i++) {
                  CString strNextChar;
                  strNextChar.Format(TEXT("%02X"), arrOutBuff[i]);
                  strDeviceInfo += strNextChar;
            }
            CString strDeviceId =
                  strDeviceInfo.Mid(40,2) +
                  strDeviceInfo.Mid(45,9) +
                  strDeviceInfo.Mid(70,6);

            return strDeviceId;
      } else {
            return _T("");
      }
}


Thanks.
0
Comment
Question by:markh51
[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
1 Comment
 
LVL 22

Accepted Solution

by:
DarkoLord earned 50 total points
ID: 11762235
Maybe this code helps: (its in vb.net)

http://forums.devbuzz.com/tm.asp?m=31761&p=1&tmode=1

Darko
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

697 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