DLL封装Interface(接口)(D2007+win764位)
.jpg)
相关资料:
http://blog.csdn.net/liangpei2008/article/details/5394911
结果注意:
1.函数的传参方向必须一至。
DLL实例代码:
ZJQInterface.pas
unit ZJQInterface; interface type
IInterface1 = interface
function Func1: Integer;
function Func2: Integer;
end; IInterface2 = interface
procedure Proc1;
procedure Proc2;
end; implementation end.
ZJQInterfaceDll.dpr
//************************************************************//
// DLL封装接口
//************************************************************//
library ZJQInterfaceDll; { 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
Dialogs,
SysUtils,
Classes,
ZJQInterface in 'ZJQInterface.pas'; type
TClass1 = class(TInterfacedObject, IInterface1, IInterface2)//可以继承一下接口
public
procedure Proc1;
procedure Proc2;
function Func1: Integer;
function Func2: Integer;
end; {$R *.res}
{ TClass1 } function TClass1.Func1: Integer;
begin
ShowMessage('IInterface1.Func1');
Result := ;
end; function TClass1.Func2: Integer;
begin
ShowMessage('IInterface1.Func2');
Result := ;
end; procedure TClass1.Proc1;
begin
ShowMessage('IInterface2.Proc1');
end; procedure TClass1.Proc2;
begin
ShowMessage('IInterface2.Proc2');
end; function CreateInterface: IInterface1; stdcall;//stdcall关键字必须有,因为UNIT1中也用到了这个,必须一至。
begin
Result := TClass1.Create;
end; exports
CreateInterface; begin
end.
EXE实例代码:
Unit1.pas
//************************************************************//
//EXE调用DLL的接口实例
//程序运行不了,请生成新的DLL放在EXE的同目录里。
//************************************************************//
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
ZJQInterface, jpeg, ExtCtrls;//引入接口单元 type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//静态调用
function CreateInterface: IInterface1; stdcall; external 'ZJQInterfaceDll.dll';//stdcall需要与DLL中的一至 var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
i1: IInterface1;
begin
i1 := CreateInterface;
i1.Func1;
//i1 := nil;//全局的接口要写这行,局部的可以不写。
end; end.
ZJQInterfaceExe.dpr
program ZJQInterfaceExe; uses
Forms,
Unit1 in 'Unit1.pas' {Form1}; {$R *.res} begin
Application.Initialize;
ReportMemoryLeaksOnShutdown := True;//打开内存溢出提示
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
DLL封装Interface(接口)(D2007+win764位)的更多相关文章
- APSC4xSeries_Ver32.exe在win764位提示缺少DLL错误解决办法
APSC4xSeries_Ver32.exe在win764位提示缺少DLL错误解决办法 从网上下载oatime_epson-me1清零软件,Stylus4xProgram_Ver32的 解决办法:还是 ...
- 64位进程调用32位dll的解决方法 / 程序64位化带来的问题和思考
最近做在Windows XP X64,VS2005环境下做32位程序编译为64位程序的工作,遇到了一些64位编程中可能遇到的问题:如内联汇编(解决方法改为C/C++代码),long类型的变化,最关键的 ...
- Delphi 中的DLL 封装和调用对象技术(刘艺,有截图)
Delphi 中的DLL 封装和调用对象技术本文刊登2003 年10 月份出版的Dr.Dobb's 软件研发第3 期刘 艺摘 要DLL 是一种应用最为广泛的动态链接技术但是由于在DLL 中封装和调用对 ...
- Java基础04 封装与接口
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 总结之前的内容,对象(object)指代某一事物,类(class)指代象的类型.对 ...
- golang面向对象和interface接口
一. golang面向对象介绍 1.golang也支持面向对象编程,但是和传统的面向对象编程有区别,并不是纯粹的面向对象语言.2.golang没有类(class),golang语言的结合体(struc ...
- C++中模块(Dll)对外暴露接口的方式
总结下C++中模块(Dll)对外暴露接口的方式: (1)导出API函数的方式这种方式是Windows中调用DLL接口的最基本方式,GDI32.dll, User32.dll都是用这种方式对外暴露系统A ...
- Java基础04 封装与接口(转载)
数据成员和方法都是同时开放给内部和外部的.在对象内部,我们利用this来调用对象的数据成员和方法.在对象外部,比如当我们在另一个类中调用对象的时,可以使用 对象.数据成员 和 对象.方法() 来调用对 ...
- java Vamei快速教程04 封装和接口
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 总结之前的内容,对象(object)指代某一事物,类(class)指代象的类型.对 ...
- WIN764位主机的虚拟机安装的xp系统串口添加
WIN764位主机的虚拟机安装的xp系统串口添加 我的电脑安装的是64位的WIN7系统,今天为了验证一个问题,需要用到6410开发板,但在安装USB驱动时无法成功安装,估计是S3C6410的USB驱动 ...
随机推荐
- 纯CSS兑现侧边栏/分栏高度自动相等(转)
这里直接介绍我认为的最佳的侧边栏/分栏高度自动相等方法.核心的CSS代码如下(数值不固定): margin-bottom:-3000px; padding-bottom:3000px; 再配合父标签的 ...
- (麻省理工免费课程)C语言内存管理和C++面向对象编程
此课程有全部讲义和习题. 课程描述实在得令人发指.翻译如下: 您是否由于自己的Python程序比同僚们的C程序慢而垂头丧气?你是否想不用JAVA实现面向对象?加入我们,学习C和C++吧!我们带您从简单 ...
- linux下配置tomcat集群的负载均衡
linux下配置tomcat集群的负载均衡 一.首先了解下与集群相关的几个概念集群:集群是一组协同工作的服务实体,用以提供比单一服务实体更具扩展性与可用性的服务平台.在客户端看来,一个集群就象是一个服 ...
- springboot 利用configureMessageConverters add FastJsonHttpMessageConverter 实现返回JSON值 null to ""
/** * 文件名:@WebConfiguration.java <br/> * @author tomas <br/> import com.alibaba.fastjson ...
- spring中InitializingBean接口使用理解(转)
InitializingBean接口为bean提供了初始化方法的方式,它只包括afterPropertiesSet方法,凡是继承该接口的类,在初始化bean的时候会执行该方法. 测试程序如下: imp ...
- Elasticsearch的基友Logstash(转)
Logstash 是一款强大的数据处理工具,它可以实现数据传输,格式处理,格式化输出,还有强大的插件功能,常用于日志处理. 一.原理 Input可以从文件中.存储中.数据库中抽取数据,Input有两种 ...
- MySQL 忘记root密码的两种处理方法
[背景] 由于各个原因,我遇到过不只一次我服务的客户忘记了MySQL的root密码:如果是普通用户还好,我们可以用root用户去改它的密码,要命 的是把root给丢了! 对于MySQL来说如果你忘记了 ...
- Mysql show processlist 排查问题
一.命令概述: mysql show full processlist 用来查看当前线程处理情况,具体信息请参考官网:https://dev.mysql.com/doc/refman/5.7/en/s ...
- Linux 密码过期(WARNING:Your password has expired )
最近遇到两次这个问题,我们公司用的是开源的堡垒机Jumpserver但是最近有两个同学遇到了 WARNING:Your password has expired 第一次遇到这个问题也没有往深了去查,当 ...
- elk 使用中遇到的问题(kafka 重复消费)
问题描述: 在使用过程中,当遇到大量报错的时候,我们到eagle后台看到报错的那个consumer的消费情况到到lag 远远大于0(正常情况应该为0),activie 节点没有,kibana面板上没 ...