Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

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

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 Value

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 file name.

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 file name, the GetClassFilefunction finds the class identifier associated with that file. An example of its use is in the OLE implementation of IMoniker::BindToObject. This calls GetClassFileto locate the object application that can open the file when a link to a file-based document is activated.

The GetClassFilefunction searches for the File Extension key in the registry that corresponds to the . extportion of the file name. 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.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header objbase.h
Library ole32.lib
Windows Embedded CE Windows CE 2.10 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also