TOP

Delphi - 创建SuperDll 持续更新(一)
2019-09-06 00:26:20 】 浏览:116
Tags:Delphi 创建 SuperDll 持续 更新

Delphi SuperDll

作为一名5年的Delpher,一直认为Delphi是桌面应用的王者,我相信其他的Delpher也这么认为。

但是,慢慢的我发现普通方式的Delphi开发会造成代码的严重臃肿,特别是MDI类大型项目、多人同时开发的情况下。

举个例子,一个Delphi常用的业务逻辑,数据导出到Excel,完全可以写成一个公用的模块放置在业务单元,子窗体用到时直接调用即可,但是一般情况下,事情并不止想象的那么简单,维护人员的思想真的一言难尽。

后来,我有了将Delphi中常用的业务逻辑功能封装成DLL的想法,所有的业务逻辑只能在DLL中实现,系统中不允许直接写业务逻辑,只能调用DLL。

这么做的好处是,相同的业务功能不会被重复开发,大大减少了代码的臃肿,同时,业务逻辑开发人员和前台开发人员独立开来,提高了开发效率。

这里就是SuperDLL的由来,后续将持续更新。

请看如下代码:

更新日志:

//初始化

//邮件发送

//FTP上传、下载

//cxGrid数据导出

  1 library SuperDll;
  2 
  3 { Important note about DLL memory management: ShareMem must be the
  4   first unit in your library's USES clause AND your project's (select
  5   Project-View Source) USES clause if your DLL exports any procedures or
  6   functions that pass strings as parameters or function results. This
  7   applies to all strings passed to and from your DLL--even those that
  8   are nested in records and classes. ShareMem is the interface unit to
  9   the BORLNDMM.DLL shared memory manager, which must be deployed along
 10   with your DLL. To avoid using BORLNDMM.DLL, pass string information
 11   using PChar or ShortString parameters. }
 12 
 13 uses
 14   SysUtils, Classes, Variants, Graphics, Controls, IdBaseComponent, IdComponent, IdFTP,
 15   IdFTPCommon, IdTCPConnection, IdTCPClient, IdMessage, IdMessageClient, IdSMTP, cxGrid,
 16   cxGridExportLink, ComObj,
 17   cxCustomData, cxGraphics,
 18   cxData, cxDataStorage, cxEdit, cxDBData, cxGridLevel,
 19   cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
 20   cxGridTableView, cxGridDBTableView;
 21 
 22 {$R *.res}
 23 
 24 function SuperDll_Init: Boolean; stdcall;
 25 begin
 26   Result := True;
 27 end;
 28 
 29 function SuperDll_Ftp_PutOrGet(vType: string; var vUserName: string; var vPassWord: string; var vHost: string; var vDir: string; var vDesFilePath: string; vSouFilePath: string): Boolean; stdcall; //2: FTP文件上传下载
 30 var
 31   IdFtp: TIdFTP;
 32 begin
 33   IdFtp := TIdFTP.Create(nil);
 34   Result := False;
 35   try
 36     with IdFtp do
 37     begin
 38       if Connected then Disconnect;
 39       Username := vUserName;
 40       Password := vPassWord;
 41       Host := vHost;
 42       Port := 21;
 43       Connect;
 44       ChangeDir(vDir);
 45       TransferType := ftBinary;
 46       if vType = 'Put' then
 47       begin
 48         Put(vSouFilePath, ExtractFileName(vSouFilePath));
 49       end
 50       else if vType = 'Get' then
 51       begin
 52         Get(ExtractFileName(vDesFilePath), vDesFilePath, True);
 53       end;
 54     end;
 55   finally
 56     IdFtp.Disconnect;
 57     IdFtp.Free;
 58     Result := True;
 59   end;
 60 end;
 61 
 62 function SuperDll_EMail_Send(vSubject: string; var vFrom: string; var vRecipients: string; var vCCList: string; var vBccList: string; var vBody: string; var vAttachment: string; var vUsername: string; var vPassword: string; var vHost: string): Boolean; stdcall;
 63 var
 64   IdSMTP: TIdSMTP;
 65   IdMessage: TIdMessage;
 66 begin
 67   Result := False;
 68   IdSMTP := TIdSMTP.Create(nil);
 69   IdMessage := TIdMessage.Create(nil);
 70   try
 71     with IdMessage do
 72     begin
 73       Clear;
 74       Subject := vSubject;
 75       From.Text := vFrom;
 76       Recipients.EMailAddresses := vRecipients;
 77       CCList.EMailAddresses := vCCList;
 78       BccList.EMailAddresses := vBccList;
 79       Priority := TIdMessagePriority(4);
 80       if Trim(vAttachment) <> '' then
 81       begin
 82         TIdAttachment.Create(MessageParts, Trim(vAttachment));
 83       end;
 84       vBody := vBody + #13#10;
 85       vBody := vBod  
		
Delphi - 创建SuperDll 持续更新(一) https://www.cppentry.com/bencandy.php?fid=86&id=250185

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Delphi - 鼠标上下滚动基础消息事.. 下一篇Delphi - 采用第三方控件TMS、SPC..

kafka-
kafka   Partit
解决android studio
Kafka史上最详细原理
Error while fetchin
【Kafka】安装与快速
    &
flume读取日志数据写
Authentication plug
Flume 自定义source
flume   三大核
ICC副本>>>
愚公移山  
Hbase架构   Hb
5 hbase-shell + &
Hbase   MapRed
MetaException(messa
Exception in thread
HIVE metastore Dupl
-->