Pocket PC serial number

Pocket PC serial number

Postby Antonio Linares » Tue Nov 15, 2005 6: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 (?):

Code: Select all  Expand view
// 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  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby josevalle » 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
User avatar
josevalle
 
Posts: 65
Joined: Fri Oct 14, 2005 6:20 pm
Location: Bilbao

Postby Maurizio » Wed Nov 16, 2005 7: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
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Pocket PC serial number

Postby claudio.driussi » Wed Nov 16, 2005 8: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.
User avatar
claudio.driussi
 
Posts: 18
Joined: Fri Nov 11, 2005 4:46 pm

Postby Antonio Linares » Wed Nov 16, 2005 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby creswinman » Thu Aug 31, 2006 3: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?
User avatar
creswinman
 
Posts: 33
Joined: Thu Aug 24, 2006 3:14 am
Location: mexico

Postby Antonio Linares » Thu Aug 31, 2006 8:12 am

Ignacio,

Doesn't FWPPC SerialNumber() work fine ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Maurizio » Thu Aug 31, 2006 9:00 am

Ignacio,

Now I use serialnumber(), it work fine.

Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby creswinman » Thu Aug 31, 2006 4: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.
User avatar
creswinman
 
Posts: 33
Joined: Thu Aug 24, 2006 3:14 am
Location: mexico

Postby Antonio Linares » Fri Sep 01, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Function serial number For Pocket PC

Postby HATHAL » Tue Sep 05, 2006 6: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
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 5 guests