Доступ к библиотеке классов Delphi Prism из Delphi XE - PullRequest
4 голосов
/ 27 мая 2011

Мне нужно получить доступ в Delphi XE к методу «Auth» из этой библиотеки классов Delphi Prism:

    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 очень дорогой, и этот код предназначен для домашнего проекта. Есть ли простой способ сделать это?

ТИА

1 Ответ

5 голосов
/ 27 мая 2011
function Auth(userName: PAnsiChar; userPassword: PAnsiChar): PAnsiChar; stdcall; external 'ClassLibrary1.dll' 

Но возвращение PAnsiChar не очень хорошая идея в неуправляемом коде / win32. Кто собирается освободить строку?

...