dbimport.~dpr

来自「导从文本文件或Excel导入数据到SQL SERVER中,自动匹配字段」· ~DPR 代码 · 共 68 行

~DPR
68
字号
library DBImport;

{ 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,
  Classes,
  Forms,
  ADODB,
  ActiveX,
  Windows,
  DB,
  DIMain in 'DIMain.pas' {frmDIMain};

var
  DLLApplication:THandle;
  DllScreen:TScreen;   

Procedure DllImport(AppHandle:THandle;DllScr:TScreen;DBCnn:TADOConnection;
DestDT:TDataSet;CfgDT:TDataSet;SqlAfterImport:Pchar;AsMdiChild:Boolean);stdcall;
begin   
  CoInitialize(Nil);
  Application.Handle:=AppHandle;
  //Screen:=DllScr;
  DllDBCnn:=DBCnn;
  DllTargetDT:=DestDT;
  SqlStr:=
  DllCfgDT:=CfgDT;
  frmDIMain:=TfrmDIMain.Create(Application);
  frmDIMain.DS_Match.DataSet :=DllCfgDT;
  frmDIMain.ShowModal; 
end;

procedure DLLUnloadProc(Reason: Integer); register;
begin
  {DLL_PROCESS_ATTACH:进程进入时
 DLL_PROCESS_DETACH进程退出时
 DLL_THREAD_ATTACH 线程进入时
 DLL_THREAD_DETACH 线程退出时}
  if Reason = DLL_PROCESS_DETACH then
  begin
    CoUnInitialize;   
    Application.Handle:=DLLApplication;
    Screen := DLLScreen;
  end;
end;

{$R *.res}

exports
  DllImport;
  
begin
  DLLApplication:=Application.Handle;
  DLLScreen := Screen;
  DLLProc := @DLLUnloadProc;
  DLLUnloadProc(DLL_PROCESS_ATTACH);
end.

⌨️ 快捷键说明

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