Delphi中的原型函数:Function DecryptionCode(EnStr,s:string):string; stdcall ;
Function LoginJudge(IP,User,Pwd,Dt :string):Boolean; stdcall ;
C#中调用方法:
using System.Runtime.InteropServices;[DllImport("LoginIdentAuth.dll")]
public static extern string DecryptionCode(string myName, string myPwd);
//
[DllImport("LoginIdentAuth.dll")]
public static extern bool LoginJudge(string IP, string User,string Pwd,string Dt);//
private void button1_Click(object sender, EventArgs e)
{
string myValue=DecryptionCode("用户名","用户密码");//用户密码有特殊符,有单引号,双引号,$,&等.运行时报错:尝试读取或写保存的内存
bool myBool=LoginJudge("192.168.0.1","sa","sa","sys");//运行时报错:外部组件发生异常
}
Function LoginJudge(IP,User,Pwd,Dt :string):Boolean; stdcall ;
C#中调用方法:
using System.Runtime.InteropServices;[DllImport("LoginIdentAuth.dll")]
public static extern string DecryptionCode(string myName, string myPwd);
//
[DllImport("LoginIdentAuth.dll")]
public static extern bool LoginJudge(string IP, string User,string Pwd,string Dt);//
private void button1_Click(object sender, EventArgs e)
{
string myValue=DecryptionCode("用户名","用户密码");//用户密码有特殊符,有单引号,双引号,$,&等.运行时报错:尝试读取或写保存的内存
bool myBool=LoginJudge("192.168.0.1","sa","sa","sys");//运行时报错:外部组件发生异常
}
delphi中的string 对应C#中的 StringBuilder
我也遇到过这样的问题
才行
public static extern string DecryptionCode(StringBuilder myName, StringBuilder myPwd);或者
[DllImport("LoginIdentAuth.dll")]
public static extern StringBuilder DecryptionCode(StringBuilder myName, StringBuilder myPwd);试试看呢