Geoff Chappell - Software Analyst
Given an arbitrary interface pointer to an object, this function calls the object’s GetClassID method.
HRESULT IUnknown_GetClassID ( IUnknown *punk, CLSID *pClassID);
The punk argument is any interface pointer for the object of interest.
The pClassID argument is for the object’s GetClassID method.
The function returns zero for success, else an error code.
The object is expected to implement the IPersist or IPersistFolder interface.
If the punk argument is NULL, then there is no object to query for the expected interfaces, and the function returns E_FAIL. Interfaces are queried in the order given above. If the object does not implement any of the expected interfaces, the function returns the result of its last call to QueryInterface.
The IPersistFolder interface is not queried unless SHELL32.DLL exports a DllGetVersion function that reports the SHELL32 version as 4.00 or higher. Even then, the QueryInterface is done with structured exception handling.
Once the function has obtained a pointer to the expected interface for the given object, it uses this interface pointer to call the GetClassID method. The pClassID argument is passed as given. The function then releases the interface pointer. The result of calling the method becomes the result of the function.
The IUnknown_GetClassID function is exported from SHLWAPI.DLL as ordinal 175 in version 5.00 and higher.
Though this function dates from as long ago as 1999, it was still not documented by Microsoft in the MSDN Library at least as late as the CD edition dated January 2004.