|MIDAS Server in NT Service Application|
|Step 3. Installation and configuration|
First of all you will need to know some features of the Windows security system. As you know, service applications are executed in another security context than the context of the currently logged on user. Usually services are installed into LocalSystem account. When DCOM server registers itself in the system registry it specifies that it will be executed as a service or as a regular Win32 application. When the DCOM server starts, the system checks the context of the server process and compares it with those stored in registry. If these contexts do not match, then an error is generated and the server stops.
Due to this feature of Windows, it is almost impossible to debug the DCOM server that lives in an NT Service. But SvCom was designed to work around this problem. To make it possible two installation modes are supported by SvCom-based service application.
First mode is the "Debug Mode". To install our example into this mode execute it with two switches :
SvComMIDAS.exe /reinstall /debug
You can do it from the command prompt or directly from the Delphi IDE. Please note that the first reinstallation will cause an exception such as "service is not installed". Ignore it, this exception is caught and suppressed internally; it is a feature of SvCom design.
After execution of this command, the registry settings of the sample application are similar to the settings of a regular DCOM server. If you try to start the service now, you will get the error message that security context of COM object differs from those in the object's settings. However, now it is possible to execute our example from the Delphi IDE with /debug switch. It will start as a regular application, and you will be able to trace and debug it if necessary.
The second supported mode is "Operational mode". In this mode the service application really operates as a service. To reinstall our example into this mode simply run it with /reinstall switch:
Now the service can't be started with /debug switch - the system will detect and prohibit it. However, now it can be executed as a real service.
Using these SvCom features you can safely debug your service if it is necessary and then switch it back into service mode - and, you can switch between these two modes as many times as you need.
|<< | Index | Step 1 | Step 2 | Step 3 | Step 4 | >>|
|Add your comment | Read comments|