C中dll:
extern "C" __declspec(dllexport) bool open(string &username)
{
}C#中:
[DllImport("File.dll")]
static extern bool open(ref string username);调用:
string username = l.username;
open(ref username);
请问下要怎么改才不会出错啊?
extern "C" __declspec(dllexport) bool open(string &username)
{
}C#中:
[DllImport("File.dll")]
static extern bool open(ref string username);调用:
string username = l.username;
open(ref username);
请问下要怎么改才不会出错啊?
你可以要求DLL作者更改函数类型,比如返回一个BSTR或者填充一个调用者预分配的缓冲区。