DevCreateObjectQueryFromIdEx function (devquery.h)

Creates a device query to retrieve properties based on the specified query parameters, extended parameters, and object ID.

Syntax

HRESULT DevCreateObjectQueryFromIdEx(
  [in]           DEV_OBJECT_TYPE                 ObjectType,
  [in]           PCWSTR                          pszObjectId,
  [in]           ULONG                           QueryFlags,
  [in]           ULONG                           cRequestedProperties,
  [in, optional] const DEVPROPCOMPKEY            *pRequestedProperties,
  [in]           ULONG                           cFilterExpressionCount,
  [in, optional] const DEVPROP_FILTER_EXPRESSION *pFilter,
  [in]           ULONG                           cExtendedParameterCount,
  [in, optional] const DEV_QUERY_PARAMETER       *pExtendedParameters,
  [in]           PDEV_QUERY_RESULT_CALLBACK      pCallback,
  [in, optional] PVOID                           pContext,
  [out]          PHDEVQUERY                      phDevQuery
);

Parameters

[in] ObjectType

A value from the DEV_OBJECT_TYPE enumeration that determines the object type that this query should operate on.

[in] pszObjectId

The string identifier for the specific object the query should operate on.

[in] QueryFlags

A combination of DEV_QUERY_FLAGS values that are combined by using a bitwise OR operation.

[in] cRequestedProperties

The number of DEVPROPCOMPKEY structures provided in pRequestedProperties. If DevQueryFlagAllProperties is specified, this must be set to 0.

[in, optional] pRequestedProperties

Optionally provides an array of DEVPROPCOMPKEY structures that specify the properties that should be retrieved for objects in the query’s result set when pCallback is called to notify the query of an addition of an object to its result set.
If DevQueryFlagUpdateResults was specified in QueryFlags, the query will be notified if the value of any of these properties changes for any object in the query’s result set.

The LocaleName field of the DEVPROPCOMPKEY structure is ignored and must be set to NULL.

If cRequestedProperties is 0, this must be NULL.

[in] cFilterExpressionCount

The number of DEVPROP_FILTER_EXPRESSION structures provided in pFilter.

[in, optional] pFilter

Optionally provides an array of DEVPROP_FILTER_EXPRESSION structures that specify filter criteria for what objects should be part of the query’s result set. If cFilterExpressionCount is 0, this must be NULL.

[in] cExtendedParameterCount

Reserved for system usage. Must be set to 0.

[in, optional] pExtendedParameters

Reserved for system usage. Must be set to NULL.

[in] pCallback

A PDEV_QUERY_RESULT_CALLBACK callback function that results for this query should be sent to.

[in, optional] pContext

Caller-supplied context. This value is passed to the callback function unmodified.

[out] phDevQuery

Pointer that receives the handle representing the query. If DevQueryFlagsUpdateResults is specified, then the query will receive updates until the handle is closed. Call DevCloseObjectQuery to close this handle to stop the query.

Return value

S_OK is returned if a query was successfully created; otherwise, an appropriate error value.

Remarks

When a client wants to retrieve data about a specific object given its identity, use this function rather than DevCreateObjectQuery with a filter. This function is more efficient.

For more information, see the remarks section of DevCreateObjectQuery, which also apply to this function. For an example of creating a device query to retrieve properties based on the specified query parameters and object ID, see DevCreateObjectQueryFromId.

Requirements

Requirement Value
Minimum supported client Windows 10 version 1809
Minimum supported server Windows Server 2019
Header devquery.h
Library Onecore.lib
DLL Cfgmgr32.dll

See also

DevCreateObjectQuery