IUnknown_QueryService function (shlwapi.h)

Retrieves an interface for a service from a specified object.

Syntax

LWSTDAPI IUnknown_QueryService(
  [in]  IUnknown *punk,
  [in]  REFGUID  guidService,
  [in]  REFIID   riid,
  [out] void     **ppvOut
);

Parameters

[in] punk

Type: IUnknown*

A pointer to the IUnknown instance of the COM object that supports the service.

[in] guidService

Type: REFGUID

The service's unique identifier (SID).

[in] riid

Type: REFIID

The IID of the desired service interface.

[out] ppvOut

Type: void**

When this method returns, contains the interface pointer requested riid. If successful, the calling application is responsible for calling IUnknown::Release using this value when the service is no longer needed. In the case of failure, this value is NULL.

Return value

Type: HRESULT

Returns S_OK if successful. Returns E_FAIL if the object does not support IServiceProvider. Otherwise, the function returns the HRESULT returned by the object's QueryService method.

Remarks

If the object passed in the punk parameter supports the IServiceProvider interface, then its QueryService method is invoked, passing the guidService, riid, and ppvOut parameters and propagating the return value. Otherwise, the function returns E_FAIL.

For those versions of Windows that do not include IUnknown_QueryService in Shlwapi.h, this function must be called directly from Shlwapi.dll using ordinal 176.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server, Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shlwapi.h
DLL Shlwapi.dll (version 5.0 or later)

See also

IServiceProvider

QueryService