I have the problem loading the DLL file and calling the functions in Python. I have tried a lot of tutorials, but still can't figure out how it works. This is my class to export as DLL file. I use simple C# code.
namespace DemoClassLib
{
public class cLib
{
public int increment(int x)
{
return x + 1;
}
}
}
After building the C# code, I get the DLL file called "DemoClassLib.dll". I use ctypes to load the DLL file. Everything is okay until now.
from ctypes import *
myDll = WinDLL('D:\\Resources\\DemoClassLib\\bin\\Debug\\DemoClassLib.dll')
Starting from that point, I can't continue. All the commands I have tried are failed.
n = c_int(1)
myDll.increment(n)
It keeps on showing me the errors. How can I call the method "increment()" in Python? And how can I pass the input and retrieve the output from that? I am very new to Python. Can someone help me please? I would be very appreciated if you can provide me the source code tutorial.
ctypes. But an alternative way could be to expose your library as a COM object and access it with win32com.