SHCoCreateInstance function

[SHCoCreateInstance is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use CoCreateInstance.]

Creates Component Object Model (COM) objects that are implemented in Shell32.dll.

Syntax

SHSTDAPI SHCoCreateInstance(
  PCWSTR      pszCLSID,
  const CLSID *pclsid,
  IUnknown    *pUnkOuter,
  REFIID      riid,
  void        **ppv
);

Parameters

pszCLSID

Type: PCWSTR

A pointer to a string to convert to a CLSID. If NULL, pclsid is used as the CLSID.

pclsid

Type: const CLSID*

The CLSID to create.

pUnkOuter

Type: IUnknown*

A pointer to outer IUnknown. Used for aggregation.

riid

Type: REFIID

A reference to the IID of the interface to retrieve through ppv.

ppv

Type: void**

When this function returns successfully, receives the interface pointer requested in riid.

Return Value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error in riid that could lead to unexpected results.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shlobj_core.h (include Shlobj.h)
Library Shell32.lib
DLL Shell32.dll (version 5.0 or later)