XLL+ Class Library (7.0)

BoostHandles Sample

Demonstrates the use of RTD handles to represent objects in Excel, where the objects are wrapped by boost::shared_ptr smart pointers


This add-in contains the code referred to in the User Guide topic Specifying a smart pointer type.

The code is based on the RtdHandleDemo sample, with the following changes:

  1. RTDHANDLES_PTR_CLASS The macro RTDHANDLES_PTR_CLASS is used to define the smart pointer type used by the object cache:

    #include <boost\shared_ptr.hpp>
    #define RTDHANDLES_PTR_CLASS boost::shared_ptr 
    #include <extensions\rtdhandles.h>

    Note that this definition must appear before the includion of rtdhandles.h.

  2. psl::CreateHandleInCache The argument passed to the global function psl::CreateHandleInCache is a reference to a smart pointer, rather than a normal pointer:

    CXlOper* Thing_Create_Impl(CXlOper& xloResult, const CXlStringArg& Name, 
        long Value)
        // End of generated code 
        boost::shared_ptr<Thing> sp_thing(new Thing(Name, Value, CXlDate::Now()));
        xloResult = psl::CreateHandleInCache(sp_thing);     
        return xloResult.Ret();


To edit the functions in this add-in, you need to load the extension file RtdHandles.xpe. See Loading an extension file for instructions.

You should also make sure that none of the following extension files is loaded, since the various types of handles are mutually exclusive.


In order to build this sample project, you need to do the following:

  1. Download and install the boost libraries. (Visit http://www.boost.org.)

  2. In the project's list of Additional Include Directories, change the directory C:\3rdParty\boost_1_46_0 to the directory where you installed the boost libraries. (The directory you select should be the parent of the main boost sub-directory.)

Classes and functions used


Sample project

Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file BoostHandles.sln or the project file BoostHandles.vcproj.

You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.

When delivered, the help files are excluded from the build. You can enable the help build by selecting the files BoostHandles.help.xml and BoostHandles.chm in the Solution Explorer, and using the right-click menu to view Properties. Select the page "Configuration Properties/General" and set the "Excluded from build" property to "No". See Generating help in the User Guide for more information.

See Also

List of Sample Projects | Specifying a smart pointer type | RtdHandleDemo sample