Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling DLL function
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  calling external function with arguments Wimpy_Wellington 7 1,344 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Calling a function (which accesses a library) from another file mouse9095 4 767 Jun-07-2023, 08:55 PM
Last Post: deanhystad
Sad Iterate randint() multiple times when calling a function Jake123 2 1,981 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  Calling a class from a function jc4d 5 1,756 Dec-17-2021, 09:04 PM
Last Post: ndc85430
  [Solved] TypeError when calling function Laplace12 2 2,832 Jun-16-2021, 02:46 PM
Last Post: Laplace12
  calling a function and argument in an input phillup7 3 2,555 Oct-25-2020, 02:12 PM
Last Post: jefsummers
  Function Recognises Variable Without Arguments Or Global Variable Calling. OJGeorge4 1 2,209 Apr-06-2020, 09:14 AM
Last Post: bowlofred
  Duplicate output when calling a custom function from the same file? road2knowledge 2 2,344 May-10-2019, 07:58 AM
Last Post: road2knowledge
  How can I prevent context switching when calling an async function? AlekseyPython 1 2,806 Feb-20-2019, 10:37 AM
Last Post: AlekseyPython
  Python calling function unexpectedly lucaswinnerton 1 1,972 Jan-24-2019, 10:40 PM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020