Solved

Reading Serial number from PDA with eVB 3.0 ?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 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