XLL+ Class Library (6.3)

psl::CreateHandleInCache

Create a handle, add it to the object cache, and return the handle

template< class T >
std::tstring CreateHandleInCache(
   T* ptr
);
template< class T >
std::tstring CreateHandleInCache(
   RTDHANDLES_PTR_CLASS<T>& sptr
);

Parameters

ptr

A pointer to an instance of type T.

sptr

A smart pointer to T. Once a smart pointer has been passed to CreateHandleInCache, the object pointed to is partially owned by the HandleCache, and will be kept alive until it is no longer in use either by the object cache, or by the library which created the object.

Return Value

Returns a string handle, which can be displayed in Excel as a value, and which can be passed to functions which accept object handles of type T.

Remarks

The add-in function that contains the call should be marked as a Handle Creator function. The value returned by this method should usually be returned immediately to Excel, e.g.:

CopyC++
Thing* thing = new Thing(Name, Value, CXlDate::Now());  
xloResult = psl::CreateHandleInCache(thing);     
return xloResult.Ret();

Implementation

HandleCache<T>CreateHandleInCache

Requirements

Header: rtdhandles.h

See Also

Global Handle Functions | Object Handles (User Guide)