void pointers with SWIG

Thomas Heller theller at python.net
Thu Mar 13 02:45:55 EST 2003


stevehanawalt at yahoo.com (Steve Hanawalt) writes:

> Hello,
> 
> I've been trying to use SWIG to gain access to a DLL from a 3rd party
> which I don't have the source code for, but I do have the .dll, the
> .h, and the .lib.  The .h contains many functions such as:
> 
> FT_STATUS FT_ListDevices(
>      PVOID pvArg1,
>      PVOID pvArg2,
>      DWORD Flags
>      );
> 
> pvArg1 and pvArg2 can be both inputs and outputs depending on the
> value of Flags.  A typical C call to this function would be:
> 
> FT_STATUS ftStatus;
> DWORD numDevs;
> 
> ftStatus = FT_ListDevices(&numDevs,NULL,FT_LIST_NUMBER_ONLY);
> 
> If all works as expected, the number of devices connected is placed
> into numDevs..
> 
> Alternatively if the function is called as:
> 
> FT_STATUS ftStatus;
> char *BufPtrs[3];
> char Buffer1[64];
> char Buffer2[64];
> DWORD numDevs;
> 
> BufPtrs[0] = Buffer1;
> BufPtrs[1] = Buffer2;
> BufPtrs[2] = NULL;
> 
> ftStatus = FT_ListDevices(BufPtrs,&numDevs,FT_LIST_ALL|FT_OPEN_BY_DESCRIPTION);
> 
> If all works as expected, the number of devices connected is placed
> into numDevs and product descriptions are placed into Buffer1 and
> Buffer2.

You could try to use ctypes, which would make it possible without
using SWIG or writing an extension:
http://starship.python.net/crew/theller/ctypes.html

You can construct weird C datatypes and call dll functions with it.

Thomas




More information about the Python-list mailing list