Tag: unmanagedexports

从具有非托管导出的C#DLL返回字符串到Inno安装脚本

我有一个C#DLL,它使用Unmanaged Exports公开一个函数,它由Inno Setup Pascal脚本直接调用。 此函数需要将字符串返回给Inno Setup。 我的问题是如何实现这一目标? 我首选的方法是将Inno Setup中的缓冲区传递给C#函数,该函数将返回此缓冲区内的字符串。 我想出了这段代码: C#function: [DllExport(“Test”, CallingConvention = CallingConvention.StdCall)] static int Test([Out, MarshalAs(UnmanagedType.LPWStr)] out string strout) { strout = “teststr”; return strout.Length; } Inno安装脚本: function Test(var res: String):Integer; external ‘Test@files:testdll.dll stdcall’; procedure test1; var Res: String; l: Integer; begin SetLength(Res,256); l := Test(Res); { Uncommenting the following line causes […]