unit Unit1;

 interface

 uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; IMyInterface = interface(IUnknown)
procedure ShowString(s: string);
end; TMyClass = class(TInterfacedObject, IMyInterface)
public
procedure ShowString(s: string);
end; TSecondClass = class(TInterfacedObject, IMyInterface)
protected
myInterface: IMyInterface;
protected
property my: IMyInterface read myInterface implements IMyInterface;
public
constructor Create(AOwner: TObject); overload;
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
myclass: TMyClass;
mySecondclass: TSecondClass;
begin
myclass := TMyClass.Create;
mySecondclass := TSecondClass.Create(nil);
myclass.ShowString('sss');
mySecondclass.my.ShowString('aaa');
myclass.Free;
mySecondclass.Free;
end; { TMyClass } procedure TMyClass.ShowString(s: string);
begin
ShowMessage(s);
end; { TSecondClass } constructor TSecondClass.Create(AOwner: TObject);
begin
myInterface := TMyClass.Create;
end; end.

Delphi 接口托管实现的更多相关文章

  1. zw版_Halcon图像库delphi接口文件

    zw版_Halcon图像库delphi接口文件 Halcon图像库delphi接口文件,根据安装时用户设置的文件目录不同,会有所差异,笔者一般安装在delphi的import目录下.     参见:& ...

  2. delphi 接口Interface

    学习 delphi 接口 一切都是纸老虎!!! 第四章          接口 前不久,有位搞软件的朋友给我出了个谜语.谜面是“相亲”,让我猜一软件术语.我大约想了一分钟,猜 出谜底是“面向对象”.我 ...

  3. Delphi 接口使用中,对象生命周期管理,如何释放需要注意的问题

    网上有篇文章<Delphi接口编程的两大陷阱>,里面提到接口的生存期管理的问题.但该文章里面提到的两个问题,其实都是对 Delphi 不理解导致的.   先说该篇文章中提到的第一个问题为什 ...

  4. 微软手写识别模块sdk及delphi接口例子

    http://download.csdn.net/download/coolstar1204/2008061 微软手写识别模块sdk及delphi接口例子

  5. Delphi接口的底层实现(接口在内存中仍然有其布局,它依附在对象的内存空间中,有汇编解释)——接口的内存结构图,简单清楚,深刻 good

    引言 接口是面向对象程序语言中一个很重要的元素,它被描述为一组服务的集合,对于客户端来说,我们关心的只是提供的服务,而不必关心服务是如何实现的:对于服务端的类来说,如果它想实现某种服务,实现与该服务相 ...

  6. C#调用Delphi接口(ITest = interface)

    首先创建一个delphi的DLL工程 library testintfdll; { Important note about DLL memory management: ShareMem must ...

  7. Delphi接口的底层实现

    引言 接口是面向对象程序语言中一个很重要的元素,它被描述为一组服务的集合,对于客户端来说,我们关心的只是提供的服务,而不必关心服务是如何实现的:对于服务端的类来说,如果它想实现某种服务,实现与该服务相 ...

  8. [Delphi]接口认识

    Delphi中的接口用 interface 进行声明.接口是针对行为方法的描述,而不管他实现这种行为方法的是对象还是别的什么东西.因此,接口和类的出发点是不一样的,是在不同的角度看问题. 接口通过GU ...

  9. Delphi接口使用实例介绍

    对于Object Pascal语言来说,最近一段时间最有意义的改进就是从Delphi3开始支持接口(interface),接口定义了能够与一个对象进行交互操作的一组过程和函数.对一个接口进行定义包含两 ...

随机推荐

  1. html中embed标签的用法

    (一).基本语法: embed src=url 说明:embed可以用来插入各种多媒体,格式可以是 Midi.Wav.AIFF.AU.MP3等等,Netscape及新版的IE 都支持.url为音频或视 ...

  2. cocos2dx ——屏幕适配

    本文出自 “夏天的风” 博客,请务必保留此出处 http://shahdza.blog.51cto.com/2410787/1550089 手机的屏幕大小千差万别,如现在流行的安卓手机屏幕大部分长宽比 ...

  3. BufferedInputStream实现原理分析

    原文地址:http://blog.sina.com.cn/s/blog_67f995260101huxz.html BufferedInputStream是一个带有缓冲区的输入流,通常使用它可以提高我 ...

  4. [POJ] 3461 Oulipo [KMP算法]

    Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23667   Accepted: 9492 Descripti ...

  5. Linux下使用VirtualBox安装Windows系统

    (文档比较长,只是写的详细,实际操作起来相对简单.) 由于一些特殊原因,我们并不能完全抛下Windows而使用Linux.VirtualBox 是一款虚拟机软件,支持多系统.在Linux下安装 Vir ...

  6. sgu To xor or not to xor

    题意:从n个数中,选择一些数,使得异或最大. #include <cstdio> #include <cstring> #include <algorithm> # ...

  7. sign starfieldtech

    signtool sign /f certfile.pfx /p password /tr http://tsa.starfieldtech.com /td SHA256 mycode.exe htt ...

  8. 【转】Android 源码下利用jni编译自己的项目(参考系统development/samples/SimpleJNI)

    原文网址:http://blog.csdn.net/qiuxiaolong007/article/details/7860481 记于正文前:环境是ubuntu10.10,android 源码是2.0 ...

  9. bzoj2049-洞穴勘测(动态树lct模板题)

    Description 辉辉热衷于洞穴勘测.某天,他按照地图来到了一片被标记为JSZX的洞穴群地区.经过初步勘测,辉辉发现这片区域由n个洞穴(分别编号为1到n)以及若干通道组成,并且每条通道连接了恰好 ...

  10. softlayer virtual machine vhd磁盘镜像导入shell脚本

    脚本