Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

To build and run this sample

  1. Open the solution inproc.sln.

  2. On the Build menu, click Build Solution.

  3. Register the server:

    1. Change the path in server\inproc.reg to the path of the inproc.dll you just built.

    2. Run regedit server\inproc.reg.

  4. 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 dispinterfaces only. Compare this sample with the MFC version to see the differences in source code.

This sample demonstrates the following keywords:

dispinterface; #import; _com_ptr_t; _variant_t; _bstr_t; _com_error

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.