| Previous | Next |
| ERROR_NOT_CHILD_WINDOW | ERROR_INVALID_THREAD_ID |
ERROR_INVALID_GW_COMMAND
The relationship selector passed to GetWindow is invalid.
ERROR_INVALID_GW_COMMAND is Win32 error 1443 (0x5A3). The uCmd parameter of GetWindow must be a documented GW_* constant such as GW_HWNDFIRST, GW_HWNDNEXT, GW_OWNER, or GW_CHILD. A menu command, show-state flag, z-order pseudo-handle, or application enum value is not interchangeable even when its integer representation fits the parameter type.
How invalid commands reach the call
- an uninitialized enum or configuration field is cast to
UINT - the code confuses
GW_*values withSW_*orGWL_*values - a wrapper accepts arbitrary integers instead of a restricted command type
- serialized data from another version introduces a value the current build does not support
- bitwise flags are combined even though
uCmdis a single selector, not a mask
Useful telemetry
Log the numeric command in decimal and hexadecimal, the symbolic enum chosen by the caller, the input HWND, its thread and process IDs, and the wrapper or feature that requested traversal. Preserve the original value before any cast. This code is commonly caused by parameter plumbing, so a stack trace and source-level command name matter more than desktop state.
Diagnostic procedure
Compare the value against the exact list accepted by GetWindow. Confirm that a binding layer or FFI declaration uses the correct parameter order and width. Search for broad integer casts and for switches whose default branch forwards an unknown value. If the program is enumerating windows, verify whether EnumWindows, EnumChildWindows, or GetWindow is actually the appropriate mechanism.
Avoid using repeated GetWindow(..., GW_HWNDNEXT) calls when a documented enumeration function expresses the task more safely. Traversal can be disrupted by windows being destroyed, and a loop can become unreliable even after the command value is fixed.
Corrective action
Represent the selector with a constrained enum, validate external input before conversion, and reject unsupported values at the wrapper boundary. Add tests for each accepted selector and for unknown values. Do not mask the number into a small range; that can silently transform corrupt input into a different valid relationship query.
Distinction from handle failures
ERROR_INVALID_WINDOW_HANDLE points to the HWND. Error 1443 points to the operation selector. A valid window still produces this error when the command is not a defined GW_* value.
Example
A generic UI helper stores both show commands and window-navigation commands in one integer field. A caller supplies SW_SHOW, and the helper forwards it to GetWindow. The API returns 1443. Splitting the field into separate typed enums makes the misuse impossible.
References
Looking for a different code? Search another status or error code.
