Next Previous Up Top Contents Index

A.2 An example COM server and client

A.2.3 Creating the client stubs library

Now we create a project for the client-side stubs of the encryption interface.

1. Choose File > New... from the main window.
2. Select Project and click OK.
The New Project wizard appears.
3. In the Project Type section, select "Interface to COM Type Library" and click Next.
4. Click Browse... and navigate to the Functional Developer examples folder.
The folder required is called Examples and is placed under the top-level Functional Developer folder.
It is usually C:\Program Files\Functional Objects\Functional Developer\Examples.
5. Go to the Documentation\RotNExample subfolder and choose the RotNExample.tlb file.
6. Click Next to continue to the next page of the wizard.
7. Select "Dispatch client interfaces" and click Next to continue to the next page of the wizard.
8. Choose "Translate all" on the next page, so that both the RotNExample COM class and the IRotNExample interface are translated. Click Next.
9. Change the name of the project to RotNExample-client-stubs.
10. Choose a suitable Location for the project.
11. Make sure that the "Dynamic Link Library (DLL)" option is chosen in the Project Settings and Templates section.
12. Make sure that the "Include any available templates" option is not chosen.
13. Click Next to continue.

We are now at the Use Libraries page. We are only defining the stubs for the client, so we do not need any unusual libraries.

14. Choose the "Simple" option and click Next.
15. Choose the "Standard IO streams and string formatting" option from "IO and system support", and click Next.
16. Choose the "Win32 API" option from "GUI support", and click Next.

Note that the "OLE Automation" option on the "OLE Automation support" page is automatically selected. That is what we want.

17. Click Next.
18. Choose the "NoneÝ" option from "Database support" and click Next.

We are now at the final page of the New Project wizard.

19. Make any changes you want to the Source File Headers section.
20. Click Finish.
The new project appears.

As with the server stubs project, we have to build this project to make the type library tool run.

21. Build the project with Project > Build.

As before, files are added to the project. The type-library-module.dylan file serves the same purpose as with the server stubs. The difference is that stubs.dylan contains different code. It defines a dispatch-client class for the IRotNExample interface:

/* Dispatch interface: IRotNExample version 0.0
 * GUID: {822ED42A-3EB1-11D2-A3CA-0060B0572A7F}
 * Description: An example interface for Functional Developer's
   Getting Started manual. 
*/

define dispatch-client <IRotNExample> uuid "{822ED42A-3EB1-11D2-A3CA-0060B0572A7F}"; property IRotNExample/key :: type-union(<integer>, <machine-word>), name: "key", disp-id: 12288; function IRotNExample/encrypt (arg-pre :: <string>) => (arg-result :: <string>), name: "encrypt", disp-id: 24576; function IRotNExample/decrypt (arg-pre :: <string>) => (arg-result :: <string>), name: "decrypt", disp-id: 24577; end dispatch-client <IRotNExample>;

This defines a class <IRotNExample> which allows a client to use the described interface.

There is also generated code corresponding to the COM class RotNExample from the type library:

/* COM class: RotNExample version 0.0
 * GUID: {C44502DB-3EB1-11D2-A3CA-0060B0572A7F}
 * Description: Implementation of IRotNExample.
 */

define constant $RotNExample-class-id = as(<REFCLSID>, "{C44502DB-3EB1-11D2-A3CA-0060B0572A7F}");

define function make-RotNExample () => (default-interface :: <IRotNExample>) let default-interface = make(<IRotNExample>, class-id: $RotNExample-class-id); values(default-interface) end function make-RotNExample;

This function creates an instance of the RotNExample COM class, and returns its default (and only) interface.


Getting Started with Functional Developer - 31 MAR 2000

Next Previous Up Top Contents Index