XLL+ Class Library (7.0)


Parses a handle composed of separated parts and extracts the key and state.

bool ExtractKeyAndState(
   const TCHAR* pszHandle,
   std::tstring& strKey,
   long& lState,
   size_t nKeyPartIndex,
   size_t nStatePartIndex



A handle, as displayed in an Excel cell. This should be composed of several parts, separated by colons (or another separator character if specified in the constructor). Two of the parts - the key and the state number - are compulsory, and their positions should be indicated by nKeyPartIndex and nStatePartIndex.


The key that is extracted from the handle is placed into strKey. The key is always in the form of a GUID, e.g.: {A6CBD52A-040D-4990-89EF-41A6721BADC6}.

The key is expected to be in the part indexed by nKeyPartIndex.


The state number that is extracted from the handle is placed into lState. The state number is expected to be in the part indexed by nStatePartIndex.


The position of the key in the list of separated parts.


The position of the state number in the list of separated parts.

Return Value

Returns true if the conversion succeeded, or false if the handle could not be successfully parsed.


This helper method is used by the standard implementation of SplitHandle, and is recommended to be used by all derived classes as well.

The handle is split into parts, separated by the character specified in the constructor. Then the parts in the positions specified by nKeyPartIndex and nStatePartIndex are extracted, and the state number is parsed. If either part is missing, or the state number cannot be parsed, the function fails and returns false.


Header: rtdhandles.h

See Also

CHandleFormatter<T> Class | CHandleFormatter<T> Methods