DLL动态调用函 //获取dll 文件路径
//公用单元函数
function dllform(dllname, funcname: string): DWORD;
// DLL动态调用函
//获取dll 文件路径
var
myinifile: Tinifile;
DllHandle: THandle;
Dllform: TCallBaseForm;
begin
DllHandle := LoadLibrary(PChar(CurWorkDLLPath +'\'+ dllname + '.dll'));
if DllHandle <> 0 then
begin
Dllform := GetProcAddress(DllHandle, PChar(funcname)); //窗体函数
if Assigned(Dllform) then
begin
Dllform(Application, Screen); //调用dll主窗
end
else
Application.MessageBox('程序文件调用错误,请联系系统管理员!', '错误', MB_OK + MB_ICONSTOP);
end
else
begin
MessageBox(0, Pchar('没有找到' + dllname + '.dll程序文件,请联系系统管理员'), '错误:加载DLL失败', MB_OK + MB_ICONSTOP); //判断dll文件是否存在
Exit;
end;
end;
//DLL
function CreateFrmLRPT01(App: TApplication; Scr: TScreen):TForm;
begin
Application := App;
Screen := Scr;
Application.CreateForm(TfrmLRPT01, frmLRPT01);
result:=frmLRPT01;
end;
exports
CreateFrmLRPT01;
//main调用函数
dllform('LRPT01','CreateFrmLRPT01');
📱 扫码关注公众号
扫描二维码关注我们,获取更多精彩内容
实时更新 · 干货满满