不废话上通用代码。
procedure TForm1.btn12Click(Sender: TObject);
type
TIntFunc = function(n: Integer): Extended; stdcall;
var
Th: Thandle;
Tf: TIntFunc;
Tp: TFarProc;
begin
Th := LoadLibrary('dll.dll'); { 装载DLL }
if Th > 0 then
try
Tp := GetProcAddress(Th, PChar('addone'));
if Tp <> nil then
begin
Tf := TIntFunc(Tp);
ShowMessage(FormatFloat('', Tf(1)));
end
else
ShowMessage('addone函数没有找到');
finally
FreeLibrary(Th); { 释放DLL }
end
else
ShowMessage('dll.dll没有找到');
end;