These classes are located in \Samples\Com\IMarshal\Sample\Dcom.
Note To use this sample, it is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.
Description
Technologies Demonstrated
These classes are generic utilities that can implement a COM server, host a Java-implemented COM object in a Single Threaded Apartment (STA), and use the COM function CoCreateInstaceEx to create remote objects.
When a COM object is created, the COM infrastructure obtains the class factory (a COM object that implements the IClassFactory or IClassFactory2 interface) for the requested object, and uses this to create an instance of the requested COM object for the user. Typically, the class factory for a Java-implemented COM object is the Microsoft virtual machine (Microsoft VM) (Msjava.dll); however, sometimes you must implement your own class factory. Implementation of a class factory for a COM object is required if you want multiple clients to access the same instance of a COM object (known as a singleton). To accomplish this, an .exe application is created, which registers the IClassFactory with the Service Control Manager (SCM) for all COM objects that it can create. This application is started whenever COM requires an instance of a specified COM object to be created. (The SCM knows which .exe or .dll to use to obtain the correct class factory for an object by looking in the registry under the Objects <CLSID> key at the InprocServer, and LocalServer keys.) For more information, see the MSDN Library documentation.
These classes show how to: