我目前正在为 C# 中的 C++ 库(debian linux 上的 dotnet core 3.1)开发包装类,并努力使用 DllImport 以下方法(取自 libs 文档):
HRESULT __stdcall InitializeEngine(
BSTR CustomerProjectID,
BSTR LicensePath,
BSTR LicensePassword,
BSTR FREngineDataFolder,
BSTR FREngineTempFolder,
VARIANT_BOOL IsSharedCPUCoresMode,
IEngine** Engine);
更新:进一步查看头文件,COM 类型是 typedef。因此,实际的签名看起来像这样:
int __stdcall InitializeEngine(
wchar_t* CustomerProjectID,
wchar_t* LicensePath,
wchar_t* LicensePassword,
wchar_t* FREngineDataFolder,
wchar_t* FREngineTempFolder,
short IsSharedCPUCoresMode,
IEngine** Engine);
我的导入目前看起来像这样:
[DllImport("FREngine", CallingConvention = CallingConvention.StdCall)]
extern static int InitializeEngine(
[MarshalAs(UnmanagedType.LPWStr)]string customerProjectID,
[MarshalAs(UnmanagedType.LPWStr)]string licensePath,
[MarshalAs(UnmanagedType.LPWStr)]string licensePassword,
[MarshalAs(UnmanagedType.LPWStr)]string frEngineDataFolder,
short isSharedCPUCoresMode,
ref IntPtr engine);
但这不起作用。这是方法签名的正确翻译吗?