|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
The ISvComObject4 interface is declared in SvComExample4_TLB file so add it to the uses section of form source.
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
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|