Navigation:  Programming Cookbook > Creating COM Components > Testing & Debugging > Debugging Out-of-Process >

Out-of-process Start Up Sequence

Previous pageReturn to chapter overviewNext page
1.Client calls CoCreateInstance() (or IClassFactory::CreateInstance()) with CLSCTX_LOCAL_SERVER context flag.
2.COM locates looks up component’s CLSID entry in the registry and uses its LocalServer32 sub-key to find the command line to start the server.
3.COM launches the .EXE using the command line from the registry (which must include the correct image path), appending the /Embedding command line flag. It then waits for the new process to register the required class factory, or for a timeout.
4.Dolphin.exe starts up, creates a VM, and asks it to load the image specified on the command line. If this image cannot be found, then the VM will display the usual message box, and the original call will eventually timeout in the client with an appropriate error code.
5.Assuming the image is found and loaded, then during start-up processing the SessionManager processes the /Embedding flag and starts up in headless mode; no windows will be opened, although the splash screen will be shown unless suppressed by the /nosplash command line flag.
6.COMClassFactory registers (using the CoRegisterClassObject API call) IUnknowns on instances of itself for all COM server object classes for which a class factory has previously been registered.
7.COM (or the client directly) calls IClassFactory::CreateInstance() on the appropriate class object that the server has just registered. This results in a call to COMClassFactory>>CreateInstance:riid:ppvObject: which creates a new instance of the Dolphin class that implements the component, and queries off the desired interface.
8.If no errors have occurred the interface pointer is returned to the client. In order to return the interface COM must “marshal” the interface pointer into the client’s process, so failure is still possible, even at this late stage, if marshalling code is not available for the interface.
9.Assuming there were no errors, and the interface could be marshalled, the client should now be in possession of an interface pointer of the type it requested onto an instance of the component it requested. The client can now use this interface pointer to directly invoke the methods of COM object, with COM marshalling the parameters and return values between the separate client and server processes.