gpt4 book ai didi

delphi - 从 Delphi XE 访问 Delphi Prism 类库

转载 作者:行者123 更新时间:2023-12-03 15:27:47 25 4
gpt4 key购买 nike

我需要在 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 并不是一个好主意。谁来释放字符串?

关于delphi - 从 Delphi XE 访问 Delphi Prism 类库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6156851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com