This sample is located in \Samples\Com\NTService.
Note To use this sample, it is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
These samples show how to build a Microsoft® Windows NT® Service using only Java, implementing the Service Main and Service Control as Java classes. They also show how to use the Windows NT Event Log with a custom message file.
The DCOM Server serves a Java-implemented COM object that is created in a single-threaded apartment. A WFC applet and an AWT-based applet have been created that use a Microsoft® J/Direct call to CoCreateInstanceEx to instantiate the served COM object remotely, without any local registry settings or installation.
The DCOM client applications are provided for connecting to the Windows NT Service. They show how to specify Proxy Security settings on COM objects from Java using a J/Direct call to CoSetProxyBlanket.
The same Windows NT Service can also be built using the Jtnsvc.exe tool and the com.ms.service classes from the Microsoft SDK for Java.
DCOM Client | The AWT applet and WFC application. These are stand-alone clients that create an instance of the served COM object. |
DCOM Server | COM Server classes that use the base Windows NT Service implementation from \Samples\Com\NTService\Sample\Ntservice and use the COM Server, single-threaded apartment, and COM method functionality from the \Samples\Com\NTService\Sample\Dcom package. TestService.java is an implementation of the same Windows NT Service using the com.ms.service and Jntsvc.exe tool. |
To compile the complete version of the custom messaging sample
The Windows NT Service consists of the Java classes that are the actual service implementation, and the Message resources that are required for writing events to the event log.
Another way of creating the Windows NT Service is to use Jexegen.exe to bundle the Java classes into an .exe file, and then using Jexegen.exe to bundle the resources into a separate .dll file. This keeps the messages separate from the executable.
By default, the makefile in \Samples\Com\NTService builds the messages in a separate .dll file. However, you can specify how you want the service built.
To build the DLL version, run the following command:
NMAKE DLL
To build the executable version, run the following command:
NMAKE EXE /f makefileVC
To compile the com.ms.server /jntsvc version of the Custom Messaging sample
The Windows NT Service built with jntsvc is essentially the same as the other version, except that the custom messaging file is not available, and a separate batch file is required for registering the COM object being served.
\Samples\Com\NTService\Sample\Dcom\*.java
This directory contains generic helper classes that call COM functions, provide Java/COM wrappers for IClassFactory, and provide Java implementations of C structures required by CoCreateInstanceEx.
\Samples\Com\NTService\Sample\NTService\*.java
This directory contains implementations of the generic Windows NT Service base class and all the Java-implemented C structures required for calling the appropriate Microsoft® Win32® API functions.
StructArray.javaThis class is used for dealing with arrays of Java-implemented C structures.
This sample shows how to use:
This sample shows how to:
This sample shows how to: