- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一个像TInterfacedObject
这样的基类,但没有引用计数(所以是一种TNonRefCountedInterfacedObject
)。
这实际上是我第n次需要这样的类(class),不知怎的,我总是一次又一次地编写(阅读:复制和粘贴)我自己的类(class)。我不敢相信没有我可以使用的“官方”基类。
RTL 中是否有一个基类实现 IInterface
但没有引用计数,我可以从中派生我的类?
最佳答案
在 Generics.Defaults 单元中定义了一个 TSingletonImplementation 类。适用于 Delphi 2009 及更高版本。
// A non-reference-counted IInterface implementation.
TSingletonImplementation = class(TObject, IInterface)
protected
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
end;
关于delphi - 是否有像 TInterfacedObject 这样的非引用计数基类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7080178/
我有一个基于 TInterfacedObject 的类。我将其添加到 TTreeNode 的 Data 属性中。 TFacilityTreeItem=class(TInterfacedObject)
我需要一个像TInterfacedObject这样的基类,但没有引用计数(所以是一种TNonRefCountedInterfacedObject)。 这实际上是我第n次需要这样的类(class),不知
According to the Delphi docs ,我可以使用 as 运算符将 TInterfacedObject 转换为接口(interface)。 但这对我不起作用。强制转换会产生编译错误
我正在基于:How can I allow a form to accept file dropping without handling Windows messages? 实现我的 IDropTa
我知道一个接口(interface)对象是引用计数的,所以不需要手动释放它。但是如果它有一个 TObject 继承的成员,我应该在析构函数中手动释放这个成员吗? 考虑以下代码: program Pro
我想实现IOleMessageFilter,如下所述: How to: Fix 'Application is Busy' and 'Call was Rejected By Callee' Erro
博客文章“Application Development with C++Builder and Delphi”说的是 Almost anything you write in Delphi can
我想知道 TInterfacedObject 派生类的实例何时被销毁以及谁调用析构函数。我写了一个ScopedLock类,它应该自动调用Release当实例超出范围时同步对象的方法。这是 C++ 中已
我需要一个类实现没有引用计数的接口(interface)。我做了以下事情: IMyInterface = interface(IInterface) ['{B84904DF-9E8A-
以下示例展示了如何开始针对接口(interface)进行编码: 来自 TMyObject = class function Add(a, b: integer): integer; end; 到
我是一名优秀的程序员,十分优秀!