诸位大侠: 近日,正在学习dll相关的知识,有些问题不明白,麻烦诸位给带问号的代码,注释一下谢了======================================
procedure TFrmMain.NCustSeekClick(Sender: TObject);
var
pproc: TFarProc;
s:string;
begin
if DllHandle <> 0 then
begin
pproc := GetProcAddress(DllHandle, 'GetFormClass');//////////////???????????
if Assigned(pproc) then/////////////////////////////////?????????
begin
GetFormClass := TGetFormClass(pproc);//////////???????????????
Form := GetFormClass('TFrmCustSeek').Create(Application);/////////////?????????????
end;
end;
end;
procedure TFrmMain.NCustSeekClick(Sender: TObject);
var
pproc: TFarProc;
s:string;
begin
if DllHandle <> 0 then
begin
pproc := GetProcAddress(DllHandle, 'GetFormClass');//////////////???????????
if Assigned(pproc) then/////////////////////////////////?????????
begin
GetFormClass := TGetFormClass(pproc);//////////???????????????
Form := GetFormClass('TFrmCustSeek').Create(Application);/////////////?????????????
end;
end;
end;
var
pproc: TFarProc;
s:string;
begin
dllhandle:=loadlibrary('XXX.dll'); //这儿缺一句,装载连接库 ,得到连接库句柄
if DllHandle <> 0 then
begin
pproc := GetProcAddress(DllHandle, 'GetFormClass');//////////////得到指向库中函数的句柄
if Assigned(pproc) then/////////////////////////////////如果函数存在,即pproc不为空
begin
GetFormClass := TGetFormClass(pproc);//////////将pproc转换成TGetFormClass型
Form := GetFormClass('TFrmCustSeek').Create(Application);////调用库中函数GetFormClass
end;
end;
end;