Page 1 of 1

Pocket PC serial number

Posted: Tue Nov 15, 2005 6:51 pm
by Antonio Linares
Our FWPPC user Hathal has found the bottom source code to detect the Pocket PC serial number. We have adapted like this, but gives wrong values (warnign: it does not work on the emulator). We leave it here just in case you want to test it or fix it (?):

Code: Select all

// 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() )

   ACTIVATE WINDOW oWnd

return nil

#pragma BEGINDUMP 

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

HB_FUNC( SERIALNUMBER ) 
{ 
	DWORD dwOutBytes;
	const int nBuffSize = 4096;
	byte arrOutBuff[ nBuffSize ];
	BOOL bResult = KernelIoControl( IOCTL_HAL_GET_DEVICEID, 0, 0, 
	                                arrOutBuff, nBuffSize, &dwOutBytes);
	char strDeviceId[ 18 ];
	char hex[ 17 ] = "0123456789ABCDEF";                              
	                                
	if( bResult == FALSE )
	{
		 hb_retc( "0" );
	}
	else
	{
	   strDeviceId[ 0 ] = hex[ arrOutBuff[ 40 ] ];	
	   strDeviceId[ 1 ] = hex[ arrOutBuff[ 41 ] ];	

	   strDeviceId[ 2 ] = hex[ arrOutBuff[ 45 ] ];	
	   strDeviceId[ 3 ] = hex[ arrOutBuff[ 46 ] ];	
	   strDeviceId[ 4 ] = hex[ arrOutBuff[ 47 ] ];	
	   strDeviceId[ 5 ] = hex[ arrOutBuff[ 48 ] ];	
	   strDeviceId[ 6 ] = hex[ arrOutBuff[ 49 ] ];	
	   strDeviceId[ 7 ] = hex[ arrOutBuff[ 50 ] ];	
	   strDeviceId[ 8 ] = hex[ arrOutBuff[ 51 ] ];	
	   strDeviceId[ 9 ] = hex[ arrOutBuff[ 52 ] ];	
	   strDeviceId[ 10 ] = hex[ arrOutBuff[ 53 ] ];	

	   strDeviceId[ 11 ] = hex[ arrOutBuff[ 70 ] ];	
	   strDeviceId[ 12 ] = hex[ arrOutBuff[ 71 ] ];	
	   strDeviceId[ 13 ] = hex[ arrOutBuff[ 72 ] ];	
	   strDeviceId[ 14 ] = hex[ arrOutBuff[ 73 ] ];	
	   strDeviceId[ 15 ] = hex[ arrOutBuff[ 74 ] ];	
	   strDeviceId[ 16 ] = hex[ arrOutBuff[ 75 ] ];	

	   strDeviceId[ 17 ] = 0;	
	   
	   hb_retc( strDeviceId );
	}   
} 

#pragma ENDDUMP 
Original source code:

Code: Select all

#include <uniqueid.h>
CString GetDeviceSerialNumber()
{
	DWORD dwOutBytes;
	const int nBuffSize = 4096;
	byte arrOutBuff[nBuffSize];
	BOOL bResult = ::KernelIoControl(IOCTL_HAL_GET_DEVICEID,
		0, 0, arrOutBuff, nBuffSize, &dwOutBytes);
	if (bResult == FALSE)
	{
		return _T("");
	}
	CString strDeviceInfo;
	for (unsigned int i = 0; i<dwOutBytes; i++) 
	{
		CString strNextChar;
		strNextChar.Format(L"%02X", arrOutBuff[i]);
		strDeviceInfo += strNextChar;
	}
	CString strDeviceId =
		strDeviceInfo.Mid(40,2) +
		strDeviceInfo.Mid(45,9) +
		strDeviceInfo.Mid(70,6);
	return strDeviceId;
}

Posted: Wed Nov 16, 2005 12:51 am
by josevalle
Hello Antonio

Does not work on my hp iPAQ

The first time say 0 the next ÌUUº0...

If I repeat the test the first time also get 0 and the second time diferent caracters.

Jose Valle

Posted: Wed Nov 16, 2005 7:27 am
by Maurizio
Detect the Pocket PC serial number is different for every brand ,
I use with VBE this DLL http://www.selectiveminds.com/products/ ... ?prodID=28


Regards Maurizio
www.nipeservice.com

Re: Pocket PC serial number

Posted: Wed Nov 16, 2005 8:32 am
by claudio.driussi
Antonio Linares wrote:Our FWPPC user Hathal has found the bottom source code to detect the Pocket PC serial number. We have adapted like this, but gives wrong values (warnign: it does not work on the emulator). We leave it here just in case you want to test it or fix it (?):
It does'nt work also on my Acer N50, but i found in the eVC4 the sample GetDeviceID which use the same api call and work on emulator and on device, maybe it can be a starting point.

Many years ago i used C language, but now i need help, here the relevant code:
#include <uniqueid.h>


// Global Variables:
GUID g_Guid;


// Forward declarations of functions included in this code module:
BOOL GetDeviceID( GUID* pGuid);

... code ...

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
... code ...

// get the device ID this function in implemented at the end of this file
GetDeviceID(&g_Guid);

... code ...
}

... code ...


BOOL GetDeviceID( GUID* pGuid)
{
BOOL fRes;
DWORD dwBytesReturned =0;
DEVICE_ID* pDevID;
int wSize;

if (NULL == pGuid)
return FALSE;

memset(pGuid, 0, sizeof(GUID));

pDevID = (DEVICE_ID*)malloc(sizeof(DEVICE_ID));
memset(pDevID, 0, sizeof(DEVICE_ID));
pDevID->dwSize = sizeof(DEVICE_ID);

fRes = KernelIoControl( IOCTL_HAL_GET_DEVICEID, NULL, 0,
pDevID, sizeof( DEVICE_ID ), &dwBytesReturned );

wSize = pDevID->dwSize;
free(pDevID);
if( (FALSE != fRes) || (ERROR_INSUFFICIENT_BUFFER != GetLastError()))
return FALSE;

pDevID = (DEVICE_ID*)malloc(wSize);
memset(pDevID, 0, sizeof(wSize));
pDevID->dwSize = wSize;
fRes = KernelIoControl( IOCTL_HAL_GET_DEVICEID, NULL, 0,
pDevID, wSize, &dwBytesReturned );

if((FALSE == fRes) || (ERROR_INSUFFICIENT_BUFFER == GetLastError()) )
return FALSE;

BYTE* pDat = (BYTE*)&pGuid->Data1;
BYTE* pSrc = (BYTE*)(pDevID) + pDevID->dwPresetIDOffset;
memcpy(pDat, pSrc, pDevID->dwPresetIDBytes);
pDat += pDevID->dwPresetIDBytes;
pSrc = (BYTE*)(pDevID) + pDevID->dwPlatformIDOffset;
memcpy(pDat, pSrc, pDevID->dwPlatformIDBytes);

return true;
}
It uses memory allocation/manipulation functions, are legal in harbour?

Claudio.

Posted: Wed Nov 16, 2005 1:30 pm
by Antonio Linares
Claudio,

We have tested your code but it looks it does not work too. We have found another sample that we are going to try at:

http://msdn.microsoft.com/library/defau ... viceid.asp

With Harbour you have to use hb_xgrab() and hb_xfree() instead of malloc() and free().

Posted: Thu Aug 31, 2006 3:09 am
by creswinman
Maurizio wrote:Detect the Pocket PC serial number is different for every brand ,
I use with VBE this DLL http://www.selectiveminds.com/products/ ... ?prodID=28


Regards Maurizio
www.nipeservice.com
Maurizio, tienes un ejemplo de como haces el llamdo a esa libreria?
Do you have a sample for call these library?

Posted: Thu Aug 31, 2006 8:12 am
by Antonio Linares
Ignacio,

Doesn't FWPPC SerialNumber() work fine ?

Posted: Thu Aug 31, 2006 9:00 am
by Maurizio
Ignacio,

Now I use serialnumber(), it work fine.

Maurizio

Posted: Thu Aug 31, 2006 4:27 pm
by creswinman
Lo siento, crei que fallaba pero ya me di cuenta que tengo problemas en Benq 50 especificamente.

Lo curioso es que en esa maquina al comparar 2 Strings Identicas me marca que son diferentes :(

El mismo programa en el simulador ye en uns Symbol funciona bien.

Posted: Fri Sep 01, 2006 8:41 am
by Antonio Linares
Ignacio,

> Lo curioso es que en esa maquina al comparar 2 Strings Identicas me marca que son diferentes

How do you compare them ? Please show the code

Function serial number For Pocket PC

Posted: Tue Sep 05, 2006 6:28 pm
by HATHAL
Welcome All
already clarified that the post laptop with Hp iPAQ Not work
found topic source
http://fivetechsoft.com/forums/viewtopic.php?t=555

If there was the emulator is identical for Hp ipaq pleas sent me to try it With New source.
_________________
regards,

hathal