hi all,
i am pretty new to Python(a very new to this forum). have been programming in C & C++.
i have a DLL written in C which i need to use. i would like to access it through Python instead of using Visual C++.
i am having a problem with this though. i hope someone here can help.
lemme start with my DLL definition:
#ifndef DLL_ABC_H
#define DLL_ABC_H
//Exported functions
#ifndef DLL_ABC
#ifdef __BORLANDC__
#define DLL_ABC _export
#else
#define DLL_ABC __declspec(dllexport) __stdcall
#endif
#endif
extern "C"
{
//Version of the DLL
extern void DLL_ABC Info_Version_ABC(char *sVersion);
extern BYTE DLL_ABC B_ABC_Function01(BYTE *pbParam1);
extern BYTE DLL_ABC B_ABC_Function02(BYTE * pbParam2,BYTE *pbParam3);
extern BYTE DLL_ABC ABC_Function03(char * sFileNameIn, char * sFileNameOut,BYTE * pbParam4);
}
#endif
basically, its the byte pointers that are causing the problem. i need to work in hexadecimal here.
(param 4 is to be read in. Funtions 01 and 02 set params that wld be used by function 3 to calculate param4.)
example of use of DLL is as such:
BYTE pbParam4[16];
BYTE pbParam1[16]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
BYTE pbParam2[16]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
BYTE pbParam3[16]={0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F};
B_ABC_Function02(pbParam2,pbParam3);
B_ABC_Function01(pbParam1);
ABC_Function03("FileIn.txt", "FileOut.txt",pbParam4);
in my Python script, i have the following:
abc = ctypes.windll.DLL_ABC
p2 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
p3 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
byte = ctypes.c_byte()
byte = abc.B_ABC_Function02(ctypes.byref(ctypes.c_void_p(p2)), ctypes.byref(ctypes.c_void_p(p3)))
p1 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
byte = abc.B_ABC_Function01(ctypes.byref(ctypes.c_void_p(p1)))
p4 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
byte = abc.Function03(ctypes.byref(ctypes.c_char_p(FileIn)), ctypes.byref(ctypes.c_char_p(FileOut)), ctypes.byref(ctypes.c_void_p(p4)))
i suppose call to functions 01 and 02 are OK. however, at Function03 call, i get an error that says "error: (10054, 'Connection reset by peer')".
i am then brought to Stream.py and a statement in "def read(self, count):" is highlighted. the statement is "buf = self.sock.recv(count)".
i believe the filenames are alright. thats pretty simple.
any advice? i'm stuck here and if this cant be solved, then i will have to use this DLL in C++.
thanx in advance.