delphi 的dll里边调用另外一个dll方法,新手怎么解决

2025-04-07 00:05:32
推荐回答(1个)
回答1:

动态加载吧,LoadLibrary

type
TCircleAreaFunc = function (const radius: double) : double; stdcall;
var
dllHandle : cardinal;
circleAreaFunc : TCircleAreaFunc;
begin
dllHandle := LoadLibrary('circle.dll') ;
if dllHandle <> 0 then
begin
@circleAreaFunc := GetProcAddress(dllHandle, 'CircleArea') ;
if Assigned (circleAreaFunc) then
circleAreaFunc(15) ; //call the function
else
ShowMessage('"CircleArea" function not found') ;
FreeLibrary(dllHandle) ;
end
else
begin
ShowMessage('circle.dll not found / not loaded') ;
end;
end;