Επεξεργασία

Κοινή χρήση μέσω


SHCoCreateInstance function (shlobj_core.h)

[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(
  [in, optional] PCWSTR      pszCLSID,
  [in, optional] const CLSID *pclsid,
  [in, optional] IUnknown    *pUnkOuter,
  [in]           REFIID      riid,
  [out]          void        **ppv
);

Parameters

[in, optional] pszCLSID

Type: PCWSTR

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

[in, optional] pclsid

Type: const CLSID*

The CLSID to create.

[in, optional] pUnkOuter

Type: IUnknown*

A pointer to outer IUnknown. Used for aggregation.

[in] riid

Type: REFIID

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

[out] 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

Requirement Value
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)