RAD Studio
ContentsIndex
PreviousUpNext
Connecting to a Server

Before you can drive an Automation server from your controller application, you must obtain a reference to an interface it supports. Typically, you connect to a server through its main interface.  

If the main interface is a dual interface, you can use the creator objects in the TypeLibName_TLB.pas file. The creator classes have the same name as the CoClass, with the prefix "Co" added. You can connect to a server on the same machine by calling the Create method, or a server on a remote machine using the CreateRemote method. Because Create and CreateRemote are class methods, you do not need an instance of the creator class to call them.

MyInterface := CoServerClassName.Create;
MyInterface := CoServerClassName.CreateRemote('Machine1');

 

pInterface = CoServerClassName.Create();
pInterface = CoServerClassName.CreateRemote("Machine1");

Create and CreateRemote return the default interface for the CoClass.  

If the default interface is a dispatch interface, then there is no Creator class generated for the CoClass. Instead, you can call the global CreateOleObject function, passing in the GUID for the CoClass (there is a constant for this GUID defined at the top of the _TLB unit). CreateOleObject returns an IDispatch pointer for the default interface.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!