Python Forum

Full Version: Calling DLL function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to call an external library (OP815M_64.DLL) and one of the functions in the DLL has the format:

GetUSBDeviceDescription(int, char**);

I am defining it in python as such:

Desc = c_wchar_p()

def GetUSBDescription(index):
windll.OP815M_64.OP930_GetUSBDeviceDescription(index, byref(Desc))



when I call the function and check the description (Desc) I get junk.

Callng this function in c++ works just fine and I get the properly formatted string out of the function.

To call the function in C++ I do something like below:

//declare the different function point types that will be used to load the DLL functions to.
typedef int(__stdcall *f_opdll2)(int, char **);

//Loadlibrary from the specified DLL.
HINSTANCE hGetProcIDDLL = LoadLibrary(L"..\\Debug\\OP815M.dll");


f_opdll2 GetUSBDeviceDescription = (f_opdll2)GetProcAddress(hGetProcIDDLL, "GetUSBDeviceDescription");

//define device description
char *devDscr

//Call the function to get the device description.
GetUSBDeviceDescription(0, &devDscr);

// display the device description
printf(devDscr);


Can someone please help as to how to call this function and get the properly formatted string out of the function?