IDispatch::GetTypeInfo Method

Retrieves the type information for an object, which can then be used to get the type information for an interface.

HRESULT GetTypeInfo(  
  unsigned int  iTInfo,         
  LCID  lcid,                   
  ITypeInfo FAR* FAR*  ppTInfo  
);

iTInfo

The type information to return. Pass 0 to retrieve type information for the IDispatch implementation.

lcid

The locale identifier for the type information. An object may be able to return different type information for different languages. This is important for classes that support localized member names. For classes that do not support localized member names, this parameter can be ignored.

ppTInfo

Receives a pointer to the requested type information object.

The return value obtained from the returned HRESULT is one of the following:

Return value

Meaning

S_OK

Success; the type information element exists.

DISP_E_BADINDEX

Failure; iTInfo argument was not 0.

The following code from the sample file Lines.cpp implements the member function GetTypeInfo:

// This function implements GetTypeInfo for the CLines collection.
STDMETHODIMP
CLines::GetTypeInfo(
      UINT iTInfo,
      LCID lcid,
      ITypeInfo FAR* FAR* ppTInfo)
{
   if (ppTInfo == NULL)
      return E_INVALIDARG;
   *ppTInfo = NULL;

   if(iTInfo != 0)
      return DISP_E_BADINDEX;

   m_ptinfo->AddRef();      // AddRef and return pointer to cached
                           // typeinfo for this object.
   *ppTInfo = m_ptinfo;

   return NOERROR;
}
 
Show:
© 2014 Microsoft