?
Solved

Reading Serial number from PDA with eVB 3.0 ?

Posted on 2004-08-09
1
Medium Priority
?
827 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 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 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