C# 在c中调用Delphi DLL“;试图读取或写入受保护的内存&引用;错误
我正在尝试导入delphi dll并使用其方法 以下是德尔菲法签名:C# 在c中调用Delphi DLL“;试图读取或写入受保护的内存&引用;错误,c#,delphi,dll,dllimport,C#,Delphi,Dll,Dllimport,我正在尝试导入delphi dll并使用其方法 以下是德尔菲法签名: function CALinkEncode(SubscriberID, MailshotID, LinkID: DWORD; sCode: PWideChar): HRESULT; stdcall; 下面是导入dll并使用函数的c代码 [DllImport(@"Decoder.dll", CharSet = CharSet.Ansi)] static extern string CALinkEncode(
function CALinkEncode(SubscriberID, MailshotID, LinkID: DWORD; sCode: PWideChar): HRESULT; stdcall;
下面是导入dll并使用函数的c代码
[DllImport(@"Decoder.dll", CharSet = CharSet.Ansi)]
static extern string CALinkEncode(
int SubscriberID,
int MailshotID,
int LinkID
);
public static string CALinkDecodeString(int cas, int cam, int cal)
{
string retvalptr = CALinkEncode(cas, cam, cal);
return retvalptr;
}
请提供帮助。您缺少一个参数,返回类型错误,字符集错误。应该是:
[DllImport(@"Decoder.dll", CharSet = CharSet.Unicode)]
static extern uint CALinkEncode(
uint SubscriberID,
uint MailshotID,
uint LinkID,
string sCode
);
我假设字符串参数是一个输入参数。如果不是,则需要将其声明为StringBuilder,并传递一个具有足够输出缓冲区容量的StringBuilder实例
.您缺少一个参数,返回类型错误,字符集错误。应该是:
[DllImport(@"Decoder.dll", CharSet = CharSet.Unicode)]
static extern uint CALinkEncode(
uint SubscriberID,
uint MailshotID,
uint LinkID,
string sCode
);
我假设字符串参数是一个输入参数。如果不是,则需要将其声明为StringBuilder,并传递一个具有足够输出缓冲区容量的StringBuilder实例