selldll.dpr

来自「三层ERP系统 (SQL)」· DPR 代码 · 共 128 行

DPR
128
字号
library SellDll;

{ 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',
  Binterface in '..\PublicDll\Binterface.pas' {frminterface},
  BillBase in '..\PublicDll\BillBase.pas' {frmBillBase},
  BillLookup in '..\PublicDll\BillLookup.pas' {frmBillLookup},
  BillManager in '..\PublicDll\BillManager.pas' {frmBillManager},
  Bsearch in '..\PublicDll\Bsearch.pas' {frmSearch},
  ImportBase in '..\PublicDll\ImportBase.pas' {frmImportBase},
  ProductQuery in '..\PublicDll\ProductQuery.pas' {frmProductQuery},
  SelectUnit in '..\PublicDll\SelectUnit.pas' {frmSelectUnit},
  SelectUnitPrice in '..\PublicDll\SelectUnitPrice.pas' {frmSelectUnitPrict},
  FormPrint in '..\PublicDll\FormPrint.pas' {frmFormPrint},
  BSell in 'BSell.pas',
  BSell_M in 'BSell_M.pas',
  ImportSellOrder in 'ImportSellOrder.pas' {frmImportSellOrder},
  LookupContract in 'LookupContract.pas',
  LookupSellOrder in 'LookupSellOrder.pas',
  MDContract in 'MDContract.pas' {frmContract},
  MDSellOrder in 'MDSellOrder.pas' {frmSellOrder},
  BaseInfo in '..\PublicDll\BaseInfo.pas' {frmBaseinfo},
  BaseInfo_M in '..\PublicDll\BaseInfo_M.pas' {frmBaseInfo_M},
  Base_Lookup in '..\PublicDll\Base_Lookup.pas' {frmBase_Lookup},
  BCustomer in '..\SystemDll\BCustomer.pas' {frmCustomer},
  BCustomer_M in '..\SystemDll\BCustomer_M.pas' {frmCustomer_M},
  BillStatus in '..\PublicDll\BillStatus.pas' {frmbillStatus},
  SellOrderStatus in 'SellOrderStatus.pas' {frmSellOrderStatus},
  ContractStatus in 'ContractStatus.pas' {frmContractStatus};

{$R *.res}

procedure LoadSellDLL(PApplication: TApplication; PForm: TForm;FormName:String;DB_Name:String;
          PCn:TSocketConnection;PUsercode:String;Badmin:boolean;PCDS:TclientDataset;
          ModuleID:integer;FunctionName:String); export; stdcall;
var
  DllProc: Pointer;             { Called whenever DLL entry point is called }
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');

   if FormName='FRMSELL' then
   begin
     if not Assigned(frmsell) then
       frmsell := Tfrmsell.Create(PForm);
   end;

   if FormName='FRMCUSTOMER' then
   begin
     if not Assigned(frmcustomer) then
       frmcustomer := Tfrmcustomer.Create(PForm);
   end;

   if FormName='FRMCONTRACT' then
   begin
     if not Assigned(frmcontract) then
       frmcontract := Tfrmcontract.Create(PForm);
   end;

   if FormName='FRMSELLORDER' then
   begin
     if not Assigned(frmsellorder) then
       frmsellorder := Tfrmsellorder.Create(PForm);
   end;

   if FormName='FRMBILLMANAGER' then
   begin
     if not Assigned(frmbillmanager) then
       frmBillManager := TfrmBillManager.Create(PForm);
   end;
end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
  if Reason = DLL_PROCESS_DETACH then
  begin
    if Assigned(frmSell) then
      frmSell.Free;
    if assigned(frmCustomer) then
      frmcustomer.Free;
    if assigned(frmContract) then
      frmcontract.Free;
    if assigned(frmsellorder) then
      frmsellorder.Free;
    if assigned(frmBillmanager) then
      frmBillManager.Free;
    Application := SaveApplication;
  end;
end;

exports
   LoadSellDLL;

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

⌨️ 快捷键说明

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