【发布时间】:2021-07-04 03:45:39
【问题描述】:
我正在将 C++ DLL Pointers-to-functions 导入 C#。
我的 C++ 代码:
class __declspec(dllexport) deviceImport
{
public:
deviceImport();
virtual ~deviceImport();
int __stdcall init(char* deviceName);
int __stdcall close();
int __stdcall getDLLVersion(char* value);
private:
int handle;
HINSTANCE hDLLDevice;
bool __stdcall getProcAddresses( HINSTANCE *p_hLibrary, const char* p_dllName, int p_count, ... );
int (__stdcall *Device_setPassword)(const char* value);
int (__stdcall *Device_getDLLVersion)(int p_handle, char* value);
};
我的代码 C#:
[DllImport(dllLocation, CallingConvention = CallingConvention.Cdecl)]
public static extern int init([MarshalAs(UnmanagedType.LPStr)]string device);
//How to Import Device_setPassword and Device_getDLLVersion functions???
我可以导入 init 函数,但你能帮我导入 Device_setPassword 和 Device_getDLLVersion 函数吗?
【问题讨论】:
-
@Blu3Souls 我已尝试按照链接中的方式编组 C++。但是不知道怎么调用解析
int (__stdcall *Device_setPassword)(const char* value);。