我使用.Net 4.5在C#中创建简单的类库。构建x86 cpu。我在Pyhton项目中使用它。但是方法在调用时没有显示正确的结果。
using RGiesecke.DllExport;
public static class SimpleLib
{
[DllExport("GetHelloWorld", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static string GetHelloWorld()
{
return "Hello World";
}
[DllExport("ReturnMyString", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static string ReturnMyString(string value)
{
return value;
}
}
我用Python称呼它:
import ctypes
hllDll = ctypes.WinDLL("C:\\SimpleLib.dll")
print(hllDll.GetHelloWord)
返回此消息:
< _FuncPtr对象位于0x037C0EB8>