ComLib.zip
(50k). Last Updated on 1/25/2016
for Delphi 3, Delphi 4, Delphi 5
ComLib is a library of useful COM
routines and classes. It also contains the ThreadComLib COM threading library
featured in my previous articles: "Understanding COM Threading using
Delphi" and "Threading Options for Delphi COM Servers". Please
see below for how to obtain these articles.
|
EventDemo.zip
(400k). Last Updated on 1/25/2016
for Delphi 3, Delphi 4, Delphi 5
requires
ComLib.pas & ThreadComLib.pas
EventDemo demonstrates a simplified
implementation of events (dispinterface callbacks) for Delphi 3, 4, 5.
This demo contains the following:
- TEventSinks/TEventSink classes (ComLib.pas).
TEventSinks is intended to be a replacement for the VCL TConnectionPoints
class. These new classes have the following enhancements:
- Fixes the memory leak problem in the VCL TEnumConnections/TEnumConnectionPoints
(D3 and D4)
- Allows easy implementation of triggering events for multiple sink clients
(you don't have to do the cumbersome IEnumConnections iteration (D3/D4) or
the FSinkList iteration (D5) everytime
you need to trigger an event for multiple clients)
- Allows easy implementation of a server object that supports multiple event
interfaces (requires some amount of work if you simply use the native VCL
classes)
If you are familiar with Visual Basic's server-side event mechanism where
all you have to do is to type :
Public Event FooEvent
to declare an event, and to type
RaiseEvent FooEvent
to trigger an event, this is what the TEventSinks & TEventSink classes
are for. In other words, the hard way is to hack IConnectionPoint and
IConnectionPointContainer and the easy way is to use TEventSinks/TEventSink
:).
|
- TSingletonComObject and
TSingletonAutoObject classes (ThreadComLib.pas). The singleton classes
provide base implementation for Delphi COM objects that need to be only
"single-instance" per server process. I've included singletons
because events sometimes need to be tied to singleton classes.
|