动态调用完整示例:(从上到下)
const
CommonDLL = 'CommonDLL.dll';
function G_EncryptAndKey(const ASrc: string; Key: string): string;
implementation
type
TEncryptAndKey = function(ASrc, Key: pchar): pchar;
var
EncryptAndKey: TEncryptAndKey;
////函数部份
function G_EncryptAndKey(const ASrc: string; Key: string): string;
var
HLib: THandle;
begin
Result := '';
HLib := LoadLibrary(CommonDLL);
if HLib = 0 then
begin
FreeLibrary(Hlib);
MessageBox(0, pChar('找不到指定的动态连接库' + CommonDLL), '错误', mb_iconwarning);
Exit;
end;
@EncryptAndKey := GetProcAddress(HLib, 'EncryptAndKey');//这应该重点看一眼,呵
if @EncryptAndKey = nil then
begin
FreeLibrary(Hlib);
exit;
end;
result := EncryptAndKey(Pchar(ASrc), pchar(Key));
FreeLibrary(Hlib);
end;