To the main page...The list of my products...Some texts...Sample applications, tips, tricks...If you need support...


 
DCOM server in service
Step 5. Writing a client application

A DCOM client for our example does not differ from ordinary DCOM clients. To implement it create new regular application and place a button on its form. Add the following lines to the OnClick event handler




 .
 .
 .
 .

procedure TExample4Form.Button1Click(Sender: TObject);
var Obj4: ISvComObject4;
begin
    Obj4:=CoSvComObject4.Create;
    ShowMessage(Obj4.Execute);
end;

The ISvComObject4 interface is declared in SvComExample4_TLB file so add it to the uses section of form source.

 

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, SvComExample4_TLB;

Now our client is ready for using. Compile it and run. When the client form appears click on button and after a couple of seconds you will see that the message 'Hello from...' appears. It means that our service was started successfully and our automation object works in service. You can play with this example modifying the source to hold interface or release it immediately and trying to connect when the service is paused or not. It will help you to understand how it works and how it can be used.

You can start our DCOM-server-in-service in debug mode too. Before doing it you should re-install in the debug mode. It is necessary because Windows detects the mode in which the DCOM server starts (as service or not) and prohibits start if configuration does not match. Well, to install the service into debug mode execute command

SvComExample4.exe /reinstall /debug

Now our example can be executed as an ordinary application and you can debug it using Delphi integrated debugger. Later when you've finish service trace, you will be able to turn it back into service mode. It can be done by command

SvComExample4.exe /reinstall

You can switch to debug mode and back as many times as you need.

<< | Index | Step 1 | Step 2 | Step 3 | Step 4 | Step 5


 
© 1998-2014 Alexey Dynnikov