懒
懒少爷
Unregistered / Unconfirmed
GUEST, unregistred user!
在DLL里:
function OpenDefineDLTemplate(Ahandle:Thandle;Conn:TAdoConnection):longint;stdcall;
begin
Application.Handle:=Ahandle;
DefineDLTemplateFrm:=TDefineDLTemplateFrm.Create(application);
Result:=longint(DefineDLTemplateFrm);
DefineDLTemplateFrm.ADOQuery1.Connection:=Conn;
DefineDLTemplateFrm.ShowModal;
end;
在主程序里:
procedure TTraceMainFrm.DefineDateCodeLotNoFormat1Click(Sender: TObject);
type
TOpenDefineDLTemplate=function(Ahandle:Thandle;Conn:TAdoConnection):longint;stdcall;
var
LibHandle:THandle;
OpenDefineDLTemplate:TOpenDefineDLTemplate;
begin
LibHandle:=LoadLibrary('MRInputLib.dll');
try
if LibHandle=0 then
raise Exception.Create('Error occur!Can not load library "MRInputLib.DLL"');
@OpenDefineDLTemplate:=GetProcAddress(LibHandle,'OpenDefineDLTemplate');
if @OpenDefineDLTemplate=nil then
raise Exception.Create('Error occur! Can not open "Define Template"')
else
OpenDefineDLTemplate(Application.Handle,DataM.ADOConn);
finally
FreeLibrary(LibHandle);
end;
end;
function OpenDefineDLTemplate(Ahandle:Thandle;Conn:TAdoConnection):longint;stdcall;
begin
Application.Handle:=Ahandle;
DefineDLTemplateFrm:=TDefineDLTemplateFrm.Create(application);
Result:=longint(DefineDLTemplateFrm);
DefineDLTemplateFrm.ADOQuery1.Connection:=Conn;
DefineDLTemplateFrm.ShowModal;
end;
在主程序里:
procedure TTraceMainFrm.DefineDateCodeLotNoFormat1Click(Sender: TObject);
type
TOpenDefineDLTemplate=function(Ahandle:Thandle;Conn:TAdoConnection):longint;stdcall;
var
LibHandle:THandle;
OpenDefineDLTemplate:TOpenDefineDLTemplate;
begin
LibHandle:=LoadLibrary('MRInputLib.dll');
try
if LibHandle=0 then
raise Exception.Create('Error occur!Can not load library "MRInputLib.DLL"');
@OpenDefineDLTemplate:=GetProcAddress(LibHandle,'OpenDefineDLTemplate');
if @OpenDefineDLTemplate=nil then
raise Exception.Create('Error occur! Can not open "Define Template"')
else
OpenDefineDLTemplate(Application.Handle,DataM.ADOConn);
finally
FreeLibrary(LibHandle);
end;
end;