Need help for calling DLL functions PASCAL
Sébastien Ramage <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Hi !
I'm trying to call a exported function of a propriatary DLL but I don't
understand how it works. (I'm not C++ or Pascal programmer)
I have the header file :
typedef struct {
int2 nbFiles;
st32 fileNames[1];
} FileList;
typedef FileList *FileListPtr;
#if !MacintoshStyleHandle
typedef Handle4D FileListHandle;
#else
typedef FileListPtr *FileListHandle;
#endif
extern ST_PASCAL ( int2) _4D_GetFileList(ConnectHandle CIDH,
FileListHandle *TheFileList);
I create something like this :
class FileList(Structure):
pass
FileList._fields_ = [
('nbFiles', int2),
('fileNames', st32 * 1),
]
FileListPtr = POINTER(FileList)
FileListHandle = Handle4D
_4D_GetFileList = _stdcall_libraries['4dopen.dll']._4D_GetFileList
_4D_GetFileList.restype = int2
_4D_GetFileList.argtypes = [ConnectHandle, POINTER(FileListHandle)]
then :
>> filelist = FileListHandle()
>> _4D_GetFileList(self.CIDH, filelist)
>> filelist
c_void_p(15990828)
But how can I retrieve my file list ????
I have a sample code in Pascal :
*function *DoGetFileList: OSErr;
*var*
Err,Count,Index : *Integer*;
TheFileList:FileListHandle;
FileNamePtr:StringPtr;
*begin*
Err := _4D_GetFileList (CIDH, TheFileList);
*if*( Err <> noErr) then DoAlert (Err, 55)
*else*
*begin*
{* TheFileList now contains a list of all the
files in your database *}
Err := DoCountFiles(Count);
*if*((Err = noErr) *and *(Count<>0)) *then*
*begin*
HLock(Handle(TheFileList));
*for *Index :=1 *to *count *do*
*begin*
FileNamePtr:=StringPtr(ORD4(TheFileList^)+BSL(Index-1,4));
{* You can read the filenames in
TheFileList *}
*end*;
HUnLock(Handle(TheFileList));
*end*;
*end*;
*if*(TheFileList<> nil) *then *DisposHandle(Handle(TheFileList));
DoGetFileList := Err;
*end*;
--
Sébastien Ramage
Service Informatique
[email protected]
04 74 06 45 39
Ets JANIN
115, rue de la république
69823 Belleville Cedex
Tel : 04 74 06 45 20
Fax : 04 74 66 11 76
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users