FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Pocket PC serial number
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pocket PC serial number
Posted: Tue Nov 15, 2005 06:51 PM
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 (?):

// 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:
#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;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 65
Joined: Fri Oct 14, 2005 06:20 PM
Pocket PC serial number
Posted: Wed Nov 16, 2005 12:51 AM

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

Jose Valle

Bilbao

Spain
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Pocket PC serial number
Posted: Wed Nov 16, 2005 07:27 AM

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

Posts: 18
Joined: Fri Nov 11, 2005 04:46 PM
Re: Pocket PC serial number
Posted: Wed Nov 16, 2005 08:32 AM
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.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pocket PC serial number
Posted: Wed Nov 16, 2005 01:30 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 33
Joined: Thu Aug 24, 2006 03:14 AM
Pocket PC serial number
Posted: Thu Aug 31, 2006 03:09 AM
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?
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pocket PC serial number
Posted: Thu Aug 31, 2006 08:12 AM

Ignacio,

Doesn't FWPPC SerialNumber() work fine ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Pocket PC serial number
Posted: Thu Aug 31, 2006 09:00 AM

Ignacio,

Now I use serialnumber(), it work fine.

Maurizio

Posts: 33
Joined: Thu Aug 24, 2006 03:14 AM
Pocket PC serial number
Posted: Thu Aug 31, 2006 04:27 PM

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.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Pocket PC serial number
Posted: Fri Sep 01, 2006 08:41 AM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM
Function serial number For Pocket PC
Posted: Tue Sep 05, 2006 06:28 PM

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

Continue the discussion