I don't know if this is what you want, but I will give it a shoot!
I use a delphi dll in one of my applications (ASP.NET) and I had to create a wrapper, I know that for winforms there is no need to create the wrapper DLL but you need to map the methods, I'm pasting 2 methods from that DLL and how do I call them:
#region DllImport
[DllImport("LicenseInterface.dll", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Auto, EntryPoint = "EncodeString")]
private static extern int _EncodeString(
[MarshalAs(UnmanagedType.LPStr)] string secret,
[MarshalAs(UnmanagedType.LPWStr)] string str,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder encodedStr,
int encodedBufferSize);
[DllImport("LicenseInterface.dll", CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Auto, EntryPoint = "DecodeString")]
private static extern int _DecodeString(
[MarshalAs(UnmanagedType.LPStr)] string secret,
[MarshalAs(UnmanagedType.LPWStr)] string str,
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder decodedStr,
int decodedBufferSize);
#endregion
public static int EncodeString(string str, ref string encodedStr)
{
StringBuilder _encodedString = new StringBuilder(2000);
int ret = _EncodeString("aYs6aL9b8722XXe43", str, _encodedString, _encodedString.Capacity);
encodedStr = _encodedString.ToString();
return ret;
}
public static int DecodeString(string str, ref string decodedStr)
{
StringBuilder _decodedString = new StringBuilder(2000);
int ret = _DecodeString("aYs6aL9b8722XXe43", str, _decodedString, _decodedString.Capacity);
decodedStr = _decodedString.ToString();
return ret;
}
public License()
{
// code...
License.DecodeKey(moduleKey, ref serial, ref moduleId, ref expirationDate, ref userData);
// more code...
}