Edit

WINI3CTARGETADDEDCALLBACK callback function (wini3c.h)

The client-defined callback invoked by the WinI3C library when a WinI3C-Target is added/enumerated. The callback is registered with WinI3CRegisterForTargetAdded.

Syntax

typedef void (CALLBACK* WINI3CTARGETADDEDCALLBACK)(
    _In_opt_ void* addedCallbackContext,
    _In_ const GUID* addedTargetDeviceInterfaceClass,
    _In_z_ PCWSTR addedTargetDeviceInterfacePath);

Parameters

[in, optional] addedCallbackContext

The optional client-supplied context to WinI3CRegisterForTargetAdded.

NULL if no context was supplied by the client.

The client may destroy this context at any time.

[in] addedTargetDeviceInterfaceClass

The vendor-defined device-interface-class of the added/enumerated WinI3C-Target.

This GUID is destroyed when the callback returns; the client shall make its own copy if it is needed later.

[in] addedTargetDeviceInterfacePath

The device-interface-path of the added/enumerated WinI3C-Target.

The device-interface-class of this device-interface-path is addedTargetDeviceInterfaceClass.

This string is destroyed when the callback returns; the client shall make its own copy if it is needed later.

This path can be passed to WinI3CInitializeTarget.

Return value

This callback does not return a value.

Remarks

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 as to 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.

Example

#include <wini3c.h>

void main()
{
    ...

    if (FAILED(WinI3CRegisterForTargetAdded(
        &GUID_DEVINTERFACE_SAMPLE_WINI3C_EXTENSION,
        context,
        EvtWinI3CTargetAdded)))
    {
        // Handle failure.
    }

    ...
}

void CALLBACK EvtWinI3CTargetAdded(
    _In_ void* addedCallbackContext,
    _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

See also

WinI3CRegisterForTargetAdded

WinI3CInitializeTarget