Here is some actual code that I used in the project to load the DLL, search for the function and configure and call this function.
import ctypes
The function in this case was one in the package of the terminal emulator, and it was very simple - it took four parameters and did not return any value (some of them were actually returned using the pointer parameters). The first parameter (1) should indicate that we want to connect to the host.
The second parameter ("Z") is the session identifier. This particular terminal emulator allowed short sessions from "A" to "Z".
The other two parameters were just the length and the other byte, the use of which eludes me at the moment (I should have documented this code a little better).
The steps were as follows:
- load the dll.
- Set the prototype and parameters for the function.
- Match this Python name (for easy calling).
- Create the necessary parameters.
- Call the function.
The ctypes library has all C data types ( int , char , short , void* , etc.) and can pass parameters either by value or by reference. There the tutorial is posted here .
source share