Page 1 of 1

I Am End Function serial number For Pocket PC

Posted: Thu Nov 17, 2005 10:08 am
by HATHAL
:D Hello All
I Am End Function serial number For Pocket PC
This Function Now works 100%
But Not (Emie) serial number
He is Identical Library Dll (SMSpec.DLL)
Thank For each Human He Aid Me
----------------
Regards, Hathal



// Serial number

#include "FWCE.ch"

function Main()

local oWnd
DEFINE WINDOW oWnd TITLE "Serial N?"

@ 2, 2 BUTTON "Serial N?" SIZE 80, 25 ACTION MsgInfo(SerialNumber(),str(len(SerialNumber()) ))

ACTIVATE WINDOW oWnd

return nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <uniqueid.h>

// Function serial number For Pocket PC
// vce source code
// by hathal
HB_FUNC( SERIALNUMBER )
{
DWORD dwOutBytes;
const int nBuffSize = 4096;;
char strDeviceInfo[200]="";
byte arrOutBuff[nBuffSize];
char strNextChar[20]="";
char SerialNo[18]="";
BOOL bRes = KernelIoControl(IOCTL_HAL_GET_DEVICEID,
0, 0, arrOutBuff, nBuffSize,
&dwOutBytes);
if (!bRes)
{
MessageBox( GetActiveWindow(),_T("could not retrieve serial number"),_T("Error"),0);
hb_retc("0");
}
for (unsigned int i = 0; i<dwOutBytes; i++)
{
sprintf(strNextChar,"%02X", arrOutBuff);
strcat(strDeviceInfo,strNextChar);
}
memcpy(SerialNo, strDeviceInfo+40, 2);
memcpy(SerialNo+2, strDeviceInfo+45,9);
memcpy(SerialNo+11, strDeviceInfo+70,6);
memcpy(SerialNo+17, "\0",1);
hb_retc(SerialNo);
}
#pragma ENDDUMP :D :D :D

Posted: Thu Nov 17, 2005 12:02 pm
by josevalle
Hello

In my hp ipaq it says:

"could not retrieve serial number"

and after a message box with 13 in the heading

Posted: Thu Nov 17, 2005 3:11 pm
by claudio.driussi
josevalle wrote:Hello

In my hp ipaq it says:
"could not retrieve serial number"
and after a message box with 13 in the heading
On my Acer N50 it give me an alphabumeric string
17 chars lenght.

Perhaps ipaq hardware don't implement seral number?

Try eVC4 demo called GetUUID, that do approximately
the same thing. If you like i can send it by e-mail.

Claudio.

View This Source

Posted: Thu Nov 17, 2005 3:21 pm
by HATHAL
Hello
Hp ipaq Not Support This Function
View This Source
I Am not testing
A sample code for iPAQ:

CString GetSerialNumber()
{
// Start CreateAssetFile.exe
PROCESS_INFORMATION pi;
if (!::CreateProcess(TEXT("\\windows\\CreateAssetFile.exe"),
NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
{
m_strCompaqIpaqId = _T("");
m_strErrorMessage += _T("Cannot run \\windows\\CreateAssetFile.exe file.");
return TEXT("");
}

// Wait until CreateAssetFile.exe will be finished
::WaitForSingleObject(pi.hProcess, INFINITE);

// Read data from cpqAssetData.dat file
HANDLE hInFile;
TCHAR strSN[65];
DWORD dwBytesRead;
hInFile = CreateFile(TEXT("\\windows\\cpqAssetData.dat"), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

if (hInFile == INVALID_HANDLE_VALUE) {
m_strCompaqIpaqId = _T("");
m_strErrorMessage += _T("Cannot read \\windows\\cpqAssetData.dat file.");
return TEXT("");
}

SetFilePointer(hInFile, 976, NULL, FILE_BEGIN);
memset(strSN, 0, 64 * sizeof(TCHAR));
ReadFile(hInFile, &strSN, 64, &dwBytesRead, NULL);
CloseHandle(hInFile);

return CString(strSN);
}

:)