[Gambas-user] Migrate VB6 project to Gambas 2.0 ?
Ron Onstenk
ronstk at ...239...
Thu Feb 21 03:27:02 CET 2008
On Thursday 21 February 2008 00:28, 2020 wrote:
> ' Gambas class file
> PRIVATE EXTERN FT_Open(intDeviceNumber AS Integer, plngHandle AS Pointer) AS Integer IN "libftd2xx"
> PRIVATE EXTERN FT_Close(plngHandle AS Pointer) AS Integer IN "libftd2xx"
> PRIVATE plngHandle AS Pointer = Alloc(4)
> PRIVATE intDeviceNumber AS Integer
>
Just downloaded the source code for libftd2xx.
Module Name: ftd2xx.h
typedef DWORD *FT_HANDLE;
FTD2XX_API
FT_STATUS WINAPI FT_Open(
int deviceNumber,
FT_HANDLE *pHandle
);
FTD2XX_API
FT_STATUS WINAPI FT_Close(
FT_HANDLE ftHandle
);
FTD2XX_API
FT_STATUS WINAPI FT_Read(
FT_HANDLE ftHandle,
LPVOID lpBuffer,
DWORD nBufferSize,
LPDWORD lpBytesReturned
);
FTD2XX_API
FT_STATUS WINAPI FT_Write(
FT_HANDLE ftHandle,
LPVOID lpBuffer,
DWORD nBufferSize,
LPDWORD lpBytesWritten
);
> Q1: What do you mean by "prototype of the function in C" in your first statement.
The above snippit.
The interesting point is in the FT_Open() *pHandle is used and for all other actions ftHandle.
Both are type of *FT_HANDLE (a pointer) but in the Open() a pointer to the pointer variable pHandle
and the other are the actual pointer set by the FT_Open().
I asume in *pHandle the FT_Open will store the pointer value to the handle.
I'm not a C veteran but maybe Benoit can explain the exact difference here.
Open(): FT_HANDLE *pHandle (give a pointer to a pointer variable to use)
Close(): FT_HANDLE ftHandle (give the pointer set by the open function)
I'm also afraid you need the VarPtr function not available in gambas<3
PRIVATE EXTERN FT_Open(intDeviceNumber AS Integer, plngHandle AS Pointer) AS Integer IN "libftd2xx"
PRIVATE EXTERN FT_Close(plngHandle AS Pointer) AS Integer IN "libftd2xx"
PRIVATE plngHandle AS Pointer = Alloc(4)
PUBLIC SUB Form_Open()
DIM returnCodes1 AS Integer
DIM returnCodes2 AS Integer
' open the device
returnCodes1 = FT_Open(0, VarPtr(plngHandle) ) '<--- the difference?
PRINT returnCodes1, plngHandle
' close the device
returnCodes2 = FT_Close(plngHandle)
PRINT returnCodes2, plngHandle
END
Ron
More information about the User
mailing list