I have a delphi dll that is defined like this
type
tSSL_connect = packed record
pssl : Pointer;
pctx : Pointer;
sock : Integer;
end;
function SSLCLT_Connect(pIPAddr: PChar;
iPort: Integer;
var pConn: tSSL_connect;
iTimeout: Integer;
bEnableNonBlockingMode: BOOL = TRUE): BOOL;
stdcall; external cltdll;
I converted to C# like this :
[StructLayout(LayoutKind.Sequential,CharSet = CharSet.Ansi, Pack=1)]
public unsafe struct tSSL_connect
{
public IntPtr pssl;
public IntPtr pctx;
public UInt32 sock;
};
[DllImport("cltdll.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern bool SSLCLT_Connect(string pIPAddr, UInt32 iPort, ref tSSL_connect pConn, UInt32 iTimeout, bool bEnableNonBlockingMode);
The call is like this :
tSSL_connect conn = new tSSL_connect();
btest = SSLCLT_Connect("127.0.0.1", 3858, ref conn, 1500, false);
It is asking to open a channel and writes it in conn. It returns false. So I can't get through. The conn objects returns null. I know that the server is receiving my call.
I think that it has something to do with the struct C# that has a wrong type. I'm pretty new to unmanaged stuff so if anyone can help getting thru.
I have only the dll. Thanks