我正在Delphi中创建一个新的组件,该组件实例化一个DLL。
我有两个问题:
谢谢回答。
Unit UMyComponent
interface
type
TMyComponent = class(TComponent)
...
procedure MyDllCall;
end;
procedure Register;
implementation
function MyDll: Longint; stdcall; external 'MyDllName.dll' name 'MyFunction'
procedure TMyComponent.MyDllCall;
var
res: LongInt;
begin
res:= MyDll;
end;
...
procedure Register;
begin
RegisterComponents('My Tab', [TMyComponent]);
end;
end.
我有两个问题:
- 当我在IDE上安装组件时,它会搜索物理DLL文件,并在路径中未找到时给出错误。我希望组件在运行时有效使用时才查找。
- 是否可以在运行时设置dll库文件名?例如:'MyDllName.dll' 可以更改为 '10029.dll' 或 'ajjdwawd.dll'
谢谢回答。
LoadLibrary
,GetProcAddress
,FreeLibrary
) 或者 延迟加载 (delayed
)。 - David Heffernan