querydll.dpr

来自「车辆管理系统」· DPR 代码 · 共 144 行

DPR
144
字号
library QueryDll;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  sharemem,
  SysUtils,
  Windows,
  forms,
  Sconnect,
  Classes,
  DBClient,
  Base in '..\PublicDll\Base.pas' {frmBase},
  Base_Dll in '..\PublicDll\Base_Dll.pas' {frmBase_DLL},
  MDIBase in '..\PublicDll\MDIBase.pas' {frmMDIBase},
  Global in '..\PublicDll\Global.pas',
  DataProcess in '..\PublicDll\DataProcess.pas',
  untCustomerRent in 'untCustomerRent.pas' {frmCustomerRent},
  BillStatus in '..\PublicDll\BillStatus.pas' {frmbillStatus},
  untvLeaseState in '..\RentDll\untvLeaseState.pas' {frmvleaseState},
  untVehicleRent in 'untVehicleRent.pas' {frmVehicleRent},
  BaseHandleSearch in '..\PublicDll\BaseHandleSearch.pas' {frmHandleSearch},
  untCustomerSearch in '..\VipDll\untCustomerSearch.pas' {frmCustomerSearch},
  BaseSearch in '..\PublicDll\BaseSearch.pas' {frmBaseSearch},
  Bsearch in '..\PublicDll\Bsearch.pas' {frmSearch},
  Binterface in '..\PublicDll\Binterface.pas' {frminterface},
  untVehicleMaint in 'untVehicleMaint.pas' {frmVehicleMaint},
  untPeccancyQuery in 'untPeccancyQuery.pas' {frmPeccancyQuery},
  untAccidentQuery in 'untAccidentQuery.pas' {frmAccidentQuery},
  untBenzineQuery in 'untBenzineQuery.pas' {frmBenzinequery},
  untWageQuery in 'untWageQuery.pas' {frmWageQuery},
  untinsurancequery in 'untinsurancequery.pas' {frminsurancequery};

{$R *.res}

procedure LoadQueryDLL(PApplication: TApplication; PForm: TForm;
          FormName:String;DB_Name:String;PCn:TSocketConnection;
          PUsercode:String;Badmin:boolean;PCDS:TclientDataset;
          ModuleID:integer;FunctionName:String;MainHandle:integer); export; stdcall;
begin
   Application:=PApplication;
   FormName := UpperCase(FormName);
   CurrentDBName:=DB_Name;
   DLLCDS:=PCDS;
   DLLUcode:=PUsercode;
   DLLSCT := PCn;
   G_Badmin:=Badmin;
   iModuleID:=ModuleID;
   sFunctionName:=FunctionName;
//   FormHandle:=MainApplicationHandle('TfrmClientMain');
   FormHandle:=MainHandle;

   if FormName='FRMVEHICLERENT' then
   begin
     if not Assigned(frmvehicleRent) then
       frmvehicleRent := TfrmvehicleRent.Create(PForm);
   end;

   if FormName='FRMCUSTOMERRENT' then
   begin
     if not Assigned(frmCustomerRent) then
       frmCustomerRent := TfrmCustomerRent.Create(PForm);
   end;

   if FormName='FRMVEHICLEMAINT' then
   begin
     if not Assigned(frmvehicleMaint) then
       frmvehicleMaint := TfrmvehicleMaint.Create(PForm);
   end;

   if FormName='FRMPECCANCYQUERY' then
   begin
     if not Assigned(frmpeccancyquery) then
       frmpeccancyquery := Tfrmpeccancyquery.Create(PForm);
   end;

   if FormName='FRMACCIDENTQUERY' then
   begin
     if not Assigned(frmaccidentquery) then
       frmaccidentquery := Tfrmaccidentquery.Create(PForm);
   end;

   if FormName='FRMBENZINEQUERY' then
   begin
     if not Assigned(frmBenzinequery) then
       frmBenzinequery := TfrmBenzinequery.Create(PForm);
   end;

   if FormName='FRMWAGEQUERY' then
   begin
     if not Assigned(frmwagequery) then
       frmwagequery := Tfrmwagequery.Create(PForm);
   end;

   if FormName='FRMINSURANCEQUERY' then
   begin
     if not Assigned(frminsurancequery) then
       frminsurancequery := Tfrminsurancequery.Create(PForm);
   end;

end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
  if Reason = DLL_PROCESS_DETACH then
  begin
    if assigned(frmvehicleRent) then
      frmvehicleRent.Free;
    if assigned(frmCustomerRent) then
      frmCustomerRent.Free;
    if assigned(frmvehicleMaint) then
      frmvehicleMaint.Free;
    if assigned(frmpeccancyquery) then
      frmpeccancyquery.Free;
    if assigned(frmaccidentquery) then
      frmaccidentquery.Free;
    if assigned(frmBenzinequery) then
      frmBenzinequery.Free;
    if assigned(frmwagequery) then
      frmWagequery.Free;
    if assigned(frminsurancequery) then
      frminsurancequery.Free;

    Application := SaveApplication;
  end;
end;

exports
   LoadQueryDLL;

begin
   SaveApplication := Application;
   DllName := 'QueryDll';
   DLLProc := @DLLUnloadProc;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?