INPROC Sample: Demonstrates an In-Process Automation Server Application (C++ Samples)
INPROC is an in-process Automation server. Unlike the other Automation server samples provided, INPROC can be loaded as a dynamic-link library (DLL) in the client's address space. This sample uses the native compiler COM support. See the MFC INPROC sample for more information.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
To build and run this sample
Open the solution inproc.sln.
On the Build menu, click Build Solution.
Register the server:
Change the path in server\inproc.reg to the path of the inproc.dll you just built.
Run regedit server\inproc.reg.
Set the ipdrive project as the startup project (right-click the project node and click Set as StartUp Project) and run this application.
The differences between this sample and the MFC sample with the same name are:
The COleDispatchDriver class is no longer necessary. Instead, #import is used to import a type library.
The _bstr_t and _variant_t wrapper classes are used to simplify operations of BSTR and VARIANT types.
__declspec(property) is used to simplify assignment operations for properties of COM objects.
COM error handling is now performed by using the _com_error class.
With the Visual C++ native compiler COM support, the resulting sample code is shorter and more efficient. The MFC-based INPROC sample uses dispinterface only. Compare this sample with the MFC version to see the differences in source code.