Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Registers a callback that is invoked when a WinI3C-Target of a vendor-defined device-interface-class is enumerated/added. WinI3C identifies WinI3C-Targets by the vendor device-interface-class GUID (configured via a WinI3C Vendor Extension INF).
This function blocks until all existing (matching) WinI3C-Targets have been enumerated by the callback.
WinI3CRegisterForTargetAdded is a Library-managed WinI3C API (the recommended way to use WinI3C). It is offered as an alternative to the standard PnP enumeration APIs (e.g. CM_Get_Device_Interface_List).
Syntax
_Must_inspect_result_
HRESULT WINAPI WinI3CRegisterForTargetAdded(
_In_ const GUID* targetDeviceInterfaceClass,
_In_opt_ void* addedCallbackContext,
_In_ WINI3CTARGETADDEDCALLBACK addedCallback);
Parameters
[in] targetDeviceInterfaceClass
The vendor-defined device-interface-class used to filter WinI3C-Targets.
This shall be a class that was previously registered by a WinI3C Vendor Extension INF.
The GUID may be destroyed by the client after the function returns.
[in, optional] addedCallbackContext
Optional client context that is passed back on each WINI3CTARGETADDEDCALLBACK invocation.
Specify NULL to not supply a context.
May be destroyed by client at any time.
[in] addedCallback
The client-defined WINI3CTARGETADDEDCALLBACK to invoke when a WinI3C-Target is enumerated/added.
The order in which WinI3C-Targets are reported to the client via this callback is not defined and may change; the client shall not depend on it.
All callbacks are serialized for a single registration (from WinI3CRegisterForTargetAdded). If the same callback is associated with multiple registrations, invocations of the callback are NOT serialized.
There is no guarantee which thread the callback is invoked on, and it may be invoked before WinI3CRegisterForTargetAdded returns.
The client shall not call WinI3CUnregisterForTargetAdded from within this callback; doing so may cause a deadlock. If the client decides from the callback that enumeration should be stopped, schedule the unregister asynchronously (e.g. with CreateThreadpoolWork).
If a WinI3C-Target is removed and re-added, it is reported again by this callback, regardless of whether it was previously reported or an old handle is present.
The client shall not throw exceptions from this callback; all exceptions are caught and ignored by the library.
Blocking this callback from returning may block other callback invocations.
Return value
On success this function returns S_OK.
On failure this function returns an appropriate HRESULT error code, including the following.
| Return code | Description |
|---|---|
| S_OK | Successfully registered. All existing (matching) WinI3C-Targets have been enumerated by the callback. |
| E_INVALIDARG | One or more parameters are invalid. |
| E_OUTOFMEMORY | Available memory is insufficient to execute this function. |
| HRESULT_FROM_WIN32(ERROR_ALREADY_REGISTERED) | The vendor-defined device-interface-class is already registered; cannot be registered for callback more than once. |
Remarks
A specific vendor-defined device-interface-class may only be registered once for callback enumeration.
If a WinI3C-Target is removed and re-added, it is enumerated again by the callback, regardless of whether it was previously enumerated or an old handle is present.
This function is thread-safe.
Example
#include <wini3c.h>
void main()
{
...
// Registered by the vendor's WinI3C extension INF.
// {9C0AC1AE-BBB7-48AA-9187-286F8D420CC4}
DEFINE_GUID(GUID_DEVINTERFACECLASS_MY_WINI3C,
0x9c0ac1ae, 0xbbb7, 0x48aa, 0x91, 0x87, 0x28, 0x6f, 0x8d, 0x42, 0x0c, 0xc4);
if (FAILED(WinI3CRegisterForTargetAdded(&GUID_DEVINTERFACECLASS_MY_WINI3C, context, EvtTargetAdded)))
{
// Handle failure.
}
...
}
void CALLBACK EvtTargetAdded(
_In_ void* pContext,
_In_ const GUID* addedTargetDeviceInterfaceClass,
_In_ const WCHAR* addedTargetDeviceInterfacePath)
{
...
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 11 25H2 October update (build 26200) |
| Target Platform | Windows |
| Header | wini3c.h |
| DLL | wini3c.dll |