financedll.dpr

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

DPR
103
字号
library FinanceDll;

{ 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},
  Global in '..\PublicDll\Global.pas',
  DataProcess in '..\PublicDll\DataProcess.pas',
  MDIBase in '..\PublicDll\MDIBase.pas' {frmMDIBase},
  BaseEdit in '..\PublicDll\BaseEdit.pas' {frmBaseEdit},
  Bsearch in '..\PublicDll\Bsearch.pas' {frmSearch},
  Binterface in '..\PublicDll\Binterface.pas' {frminterface},
  untOtherReceipt in 'untOtherReceipt.pas' {frmOtherReceipt},
  untOtherPay in 'untOtherPay.pas' {frmOtherPay},
  untFinanceCollect in 'untFinanceCollect.pas' {frmFinanceCollect},
  untFinanceBalance in 'untFinanceBalance.pas' {frmFinanceBalance};

{$R *.res}

procedure LoadFinanceDLL(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='FRMOTHERRECEIPT' then
   begin
     if not Assigned(frmotherreceipt) then
       frmotherreceipt := Tfrmotherreceipt.Create(PForm);
   end;

   if FormName='FRMOTHERPAY' then
   begin
     if not Assigned(frmotherpay) then
       frmotherpay := Tfrmotherpay.Create(PForm);
   end;

   if FormName='FRMFINANCEBALANCE' then
   begin
     if not Assigned(frmfinanceBalance) then
       frmfinanceBalance := TfrmfinanceBalance.Create(PForm);
   end;

   if FormName='FRMFINANCECOLLECT' then
   begin
     if not Assigned(frmfinanceCollect) then
       frmfinanceCollect := TfrmfinanceCollect.Create(PForm);
   end;

end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
  if Reason = DLL_PROCESS_DETACH then
  begin
    if assigned(frmOtherReceipt) then
      frmOtherReceipt.Free;
    if assigned(frmOtherPay) then
      frmOtherPay.Free;
    if assigned(frmfinanceBalance) then
      frmfinanceBalance.Free;
    if assigned(frmfinanceCollect) then
      frmfinanceCollect.Free;
    Application := SaveApplication;
  end;
end;

exports
   LoadFinanceDLL;

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

⌨️ 快捷键说明

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