Solved

Reading Serial number from PDA with eVB 3.0 ?

Posted on 2004-08-09
1
817 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 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

23 Experts available now in Live!

Get 1:1 Help Now