これがあなたが望むものなのかどうかわかりませんが、私はそれを撮影します!
私のアプリケーション(ASP.NET)でdelphi dllを使用していて、ラッパーを作成しなければなりませんでしたが、winformsの場合、ラッパーDLLを作成する必要はありませんが、そのDLLから2つのメソッドを貼り付け、どのように呼び出すのですか?
#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...
}