Hi, I have a Delphi 6 DLL that I need to run from C#.Net 2.0. I have some problems with it though.
Here Goes:
The Delphi Decalration is :
And the C# Declaration is :
This gives me an AccessViolationException at RunTime when I call M_Login.
I can Change the Delphi Declaration to expect Strings instead of PChars, this avoids the AccessViolationError, but this causes the values passed to the Delphi DLL to be incorrect. i.e. contain characters that the C# Application did not pass. I passed the value "127.0.0.1" as the ip parameter in C# and when I inspected the ip parameter in Delphi it was '1'#0'2'#0'7'#0'.'#0'0' .
Can anyone help, I have also posted in the C# Forum, incase it is a C# issue.
Thanx!
Dave Shaw
Nothing is Impossible, it is just something I haven't got round to doing. - Me
History admires the wise, but elevates the brave. - Edmund Morris
Here Goes:
The Delphi Decalration is :
Code:
function M_Login(ip : PChar; port : LongInt; uci : PChar; vol : PChar; pass : PChar; user : PChar) : LongInt; stdCall;
Code:
[DllImport("iMSMAPI.DLL", CallingConvention = CallingConvention.StdCall, CharSet=CharSet.Ansi)]
private static extern Int64 M_Login(string ip, Int64 port, string uci, string vol, string pass, string user);
I can Change the Delphi Declaration to expect Strings instead of PChars, this avoids the AccessViolationError, but this causes the values passed to the Delphi DLL to be incorrect. i.e. contain characters that the C# Application did not pass. I passed the value "127.0.0.1" as the ip parameter in C# and when I inspected the ip parameter in Delphi it was '1'#0'2'#0'7'#0'.'#0'0' .
Can anyone help, I have also posted in the C# Forum, incase it is a C# issue.
Thanx!
Dave Shaw
Nothing is Impossible, it is just something I haven't got round to doing. - Me
History admires the wise, but elevates the brave. - Edmund Morris