从Delphi XE访问Delphi Prism类库

问题描述

| 我需要在Delphi XE中从此Delphi Prism类库中访问方法\“ Auth \”:
    namespace ClassLibrary1;

    interface

    uses
      System,System.IO,System.Security.Cryptography,System.Runtime.InteropServices,System.Text;

    type
      ConsoleApp = public class
      private
        class method hashMe(input: string): string;
        class method Encrypt(clearText: string; Password: string; Salt: array of byte; iteration: Integer): string;
        class method Encrypt(clearData: array of byte; Key: array of byte; IV: array of byte): array of byte;
        class method Encrypt(clearData: array of byte; Password: string; Salt: array of byte; iteration: integer): array of byte;
        class method Decrypt(cipherText: string; Password: string; Salt: array of byte; iterations: Integer): string;
        class method Decrypt(cipherData: array of byte; Password: string; Salt: array of byte; iterations: integer): array of byte;
        class method Decrypt(cipherData: array of byte; Key: array of byte; IV: array of byte): array of byte;
      protected
      public
        [UnmanagedExport(\'Auth\')]
        class method Auth(userName: String; userPassword: String): String;
      end;

    implementation
[...]
使用Crosstalk非常容易,但是Crosstalk非常昂贵,并且此代码用于宠物项目。有任何简单的方法吗? TIA     

解决方法

        
function Auth(userName: PAnsiChar; userPassword: PAnsiChar): PAnsiChar; stdcall; external \'ClassLibrary1.dll\' 
但是,在非托管/ win32代码中,返回PAnsiChar并不是一个好主意。谁将释放字符串?     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...