Edit

WinI3CGetStatusFromOperation function (wini3c.h)

Retrieves the current status of a WinI3C-Target from a completed overlapped operation started with WinI3CGetStatusWithFileHandle.

The underlying overlapped operation shall have completed before this function is called.

WinI3CGetStatusFromOperation is a Non-library-managed WinI3C API, intended only for advanced scenarios and generally not recommended.

Syntax

_Must_inspect_result_
HRESULT WINAPI WinI3CGetStatusFromOperation(
    _In_ HANDLE targetFileHandle,
    _In_ OVERLAPPED* getStatusOverlapped,
    _In_ WinI3CAsyncOperation getStatusOperation,
    _Out_ WINI3C_TARGET_STATUS* targetStatus);

Parameters

[in] targetFileHandle

The file handle associated with the WinI3C-Target.

[in] getStatusOverlapped

The client-allocated OVERLAPPED that was supplied to WinI3CGetStatusWithFileHandle.

[in] getStatusOperation

The WinI3CAsyncOperation created by WinI3CGetStatusWithFileHandle.

[out] targetStatus

A pointer to a client-allocated WINI3C_TARGET_STATUS that receives the WinI3C-Target's status.

Valid only when the function returns S_OK.

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 The overlapped operation completed and the status may be inspected.
E_INVALIDARG One or more parameters are invalid.
E_OUTOFMEMORY Available memory is insufficient to execute this function.
HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE) targetFileHandle is invalid, or was not opened with FILE_FLAG_OVERLAPPED.
HRESULT_FROM_WIN32(ERROR_IO_PENDING) The overlapped operation has not completed.
HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) The overlapped operation returned more data than expected.
HRESULT_FROM_WIN32(ERROR_DEVICE_NACKED) The WinI3C-Target (passively) NACKed the GETSTATUS CCC.
HRESULT_FROM_WIN32(ERROR_DEVICE_HARDWARE_ERROR) A fatal hardware error occurred. Close targetFileHandle with CloseHandle.

Remarks

Vendors understand the capabilities of their devices, so there is no provided mechanism to determine if GETSTATUS CCC is supported.

GETSTATUS is often useful for diagnosing why another CCC or transfer was NACKed by the WinI3C-Target.

The library-created getStatusOperation shall be destroyed with WinI3CRelease.

This function is thread-safe.

Example

#include <wil\result.h>
#include <wil\resource.h>

#include <wini3c.h>

int main()
{
    ...

    auto destroyOperationOnExit = wil::scope_exit([&]()
    {
        WinI3CRelease(getStatusOperation);
    });

    // Blocking, waiting for result (for demonstration purposes only).
    // In a real application, would use a completion port or other async mechanism to avoid blocking the thread.
    DWORD numberOfBytesTransferred;
    if (!GetOverlappedResult(winI3cTargetHandle, &getStatusOverlapped, &numberOfBytesTransferred, true))
    {
        RETURN_LAST_ERROR();
    }

    WINI3C_TARGET_STATUS currentStatus;
    RETURN_IF_FAILED(WinI3CGetStatusFromOperation(
        winI3cTargetHandle,
        &getStatusOverlapped,
        getStatusOperation,
        &currentStatus));

    ...
}

Requirements

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

See also

WinI3CGetStatusWithFileHandle

WinI3CGetStatus

WINI3C_TARGET_STATUS