GetClassFile

This function supplies the class identifier associated with the specified file name.

At a Glance

Header file: Objbase.h
Windows CE versions: 2.10 and later

Syntax

WINOLEAPI GetClassFile ( LPCWSTR szFileName, CLSID * pclsid);

Parameters

szFileName

[in] Null-terminated string that contains the file name for which you are requesting the associated class identifier.

pclsid

[out] Pointer to the location where the associated class identifier is written on return.

Return Values

One of the values described in the following table is returned.

Value Description
S_OK Indicates the class identifier was successfully supplied.
MK_E_CANTOPENFILE Indicates unable to open the specified filename.
MK_E_INVALIDEXTENSION Indicates the specified extension in the registry is invalid.

This function can also return any file system errors.

Remarks

When given a filename, the GetClassFile function finds the class identifier associated with that file. Examples of its use are in OleCreateFromFile, which is passed a file name and requires an associated class identifier, and in the OLE implementation of IMoniker::BindToObject, which, when a link to a file-based document is activated, calls GetClassFile to locate the object application that can open the file.

The GetClassFile function searches for the File Extension key in the registry that corresponds to the .ext portion of the filename. If the database entry contains a valid class identifier, this function returns that class identifier.

If the File Extension key is not found or the database entry contains an invalid class identifier, the function returns MK_E_INVALIDEXTENSION.

See Also

StringFromCLSID, WriteClassStg