Share via


Getting the Class ID of the Data Source Object

Consumers can retrieve the class ID of the data source object by calling IPersist::GetClassID. Generally, the consumer does this only when the provider does not support IPersistFile and the consumer wants to persist the class ID and initialization property values for later use.

The source code for IPersist::GetClassID follows; you can find the complete source code for the IPersist interface in Persist.cpp.

// CImpIPersist::GetClassID --------------------------------------------------
//
// @mfunc Get the CLSID of the DSO.
//
// @rdesc HRESULT
//      @flag S_OK                  | The method succeeded.
//      @flag E_FAIL                | Provider-specific error.
//
STDMETHODIMP CImpIPersist::GetClassID
( 
   CLSID *pClassID 
)
{
    //
    // Check in-params and NULL out-params in case of error
    //
   if( !pClassID )
      return (E_FAIL);
   
   memcpy(pClassID, &CLSID_SampProv, sizeof(CLSID));
   return (S_OK);
}

See Also

Tasks

Writing an OLE DB Provider: An Introduction