Edit

WINI3CTARGETREMOVEDCALLBACK callback function (wini3c.h)

The client-defined callback invoked by the WinI3C library when a WinI3C-Target has been removed (e.g. the WinI3C-Target was disabled via DeviceManager, the HostController-Instance experienced a fatal error). The callback is supplied to WinI3CInitializeTarget.

Syntax

typedef void (CALLBACK* WINI3CTARGETREMOVEDCALLBACK)(
    _In_opt_ void* removedCallbackContext,
    _In_ WinI3CTarget removedTarget);

Parameters

[in, optional] removedCallbackContext

The optional client-supplied context to WinI3CInitializeTarget.

NULL if no context was supplied by the client.

The client may destroy this context at any time.

[in] removedTarget

The removed WinI3CTarget handle.

The handle is now invalid for operations and shall be destroyed by the client with WinI3CRelease, which may be called from within this callback.

Return value

This callback does not return a value.

Remarks

All outstanding I/O for removedTarget is canceled before this callback is invoked.

All new I/O for removedTarget shall fail with HRESULT_FROM_WIN32(ERROR_DEVICE_NOT_CONNECTED).

Calling WinI3CRelease does not invoke this callback.

The order in which WinI3C-Targets are reported removed is not defined and may change.

There is no guarantee as to which thread the callback is invoked on, and it may be invoked before WinI3CInitializeTarget returns.

The client shall not throw exceptions from this callback; all exceptions are caught and ignored by the library.

Example

#include <wini3c.h>

void main()
{
    ...

    if (FAILED(WinI3CInitializeTarget(
        addedTargetDeviceInterfacePath,
        context,
        EvtTargetInitialized,
        context,
        EvtTargetRemoved)))
    {
        // Handle failure.
    }

    ...
}

void CALLBACK EvtTargetInitialized(
    _In_opt_ void* initializedCallbackContext,
    _In_ WinI3CTarget initializedTarget)
{
    ...
}

void CALLBACK EvtTargetRemoved(
    _In_opt_ void* removedCallbackContext,
    _In_ WinI3CTarget removedTarget)
{
    ...
}

Requirements

Requirement Value
Minimum supported client Windows 11 25H2 October update (build 26200)
Target Platform Windows
Header wini3c.h

See also

WinI3CInitializeTarget

WINI3CTARGETINITIALIZEDCALLBACK

WinI3CRelease