I reinstall FwPPc. In previous version function GetDeviceId works fine. In this moment this function produce GPF error. Maybe my code is wrong ?
Regards
Pawel
Code: Select all
#Include 'FwCe.Ch'
Function Serial ()
MsgInfo (DeviceId ())
Return .T.
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>
#include <uniqueid.h>
#include <objbase.h>
#define MAXSTR 100
BOOL GetDeviceID (GUID* pGuid);
HB_FUNC (DEVICEID)
{
GUID Guid;
WCHAR szData[MAXSTR];
char * szId = "";
GetDeviceID (&Guid);
StringFromGUID2 (Guid, szData, MAXSTR);
wcstombs (szId, (WCHAR *) szData, MAXSTR);
hb_retc (szId);
hb_xfree (szId);
}
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;
}
#pragma ENDDUMP