Simple C++ Component

Overview

The Microsoft Development Studio environment provides you with a number of tools and wizards that make creating components in C++ faster and easier. A great deal of the overhead work of managing the DLL server and setting up the COM objects and interfaces can be accomplished automatically. The beauty of C++ components, however, lies in flexibility: if you want to be exposed to and responsible for all the gory details of your new component, then you can bypass the wizards and get your hands dirty doing the work yourself.

This sample demonstrates how to implement a component that exposes a property and a simple method.

Code Tour

This sample implements the ISimple interface, which inherits IDispatch. There are three methods provided by the ISimple interface. The first pair of methods, put_myProperty and get_myProperty, along with the BSTR member variable m_bstrMyProperty, constitute an Automation property. Like any COM component with a dual interface, C++ programs that instantiate this sample would need to call the get_ or put_myProperty methods to retrieve or set the property value, while a VB or VBScript application could access the property value with the standard Object.myProperty notation.

The third method of the ISimple interface, myMethod, converts all the characters contained in the member variable m_bstrMyProperty to uppercase.

Location

This project is available in the ...\components\c++\simple subdirectory of the IIS samples directory.