| Previous | Next |
| STG_E_UNIMPLEMENTEDFUNCTION | STG_E_INUSE |
STG_E_INVALIDFLAG
Invalid structured-storage flag combination
STG_E_INVALIDFLAG is HRESULT 2147680511 (0x800300FF) from winerror.h. AllStat describes it as “Invalid flag error.” The result belongs to STGM, commit, enumeration, or provider-specific flags passed to a storage API. The important boundary is not merely failure but which object and state transition established: the flag value contains unknown bits or a combination forbidden by the method contract.
The decisive meaning of this result is that the flag value contains unknown bits or a combination forbidden by the method contract. The severity bit does not decide handling; the controlling fact is that the flag value contains unknown bits or a combination forbidden by the method contract. Interpret it at the native boundary before a wrapper hides the condition that the flag value contains unknown bits or a combination forbidden by the method contract.
Where the result appears
- This result can surface in a IStorage, IStream, ILockBytes, property storage, compound-file parsing, or persistence code.
- map the failure to one concrete operation among StgOpenStorage, StgCreateStorageEx, IStorage, IStream, IPropertyStorage, STATSTG, and the selected STGM mode.
- Preserve storage path or identity, STGM mode, stream or storage name, transaction generation, file hash, and backing provider before releasing or replacing the object that returned this result.
An incident record for it must distinguish caller, runtime, provider, and backing resource while testing whether the flag value contains unknown bits or a combination forbidden by the method contract.
Typical causes and interpretation boundary
The immediate contract boundary is specific: the flag value contains unknown bits or a combination forbidden by the method contract. Common cause branches include the following:
- Mutually exclusive access modes are combined.
- A flag intended for creation is passed to an open operation.
- A newer flag reaches an older implementation.
Confirm the cause branch that explains why the flag value contains unknown bits or a combination forbidden by the method contract by using call arguments, object state, metadata, device information, or provider traces.
Correct handling and recovery
The primary recovery is to construct flags from named constants for the exact API and negotiate version support before retry. The result failure report should expose enough STGM, commit, enumeration, or provider-specific flags passed to a storage API state to understand why the flag value contains unknown bits or a combination forbidden by the method contract without a production debugger.
Retry this result only when evidence shows the state behind “the flag value contains unknown bits or a combination forbidden by the method contract” can change and the operation is repeatable. Reconcile persistent, remote, device, or ownership state before repeating it.
Practical scenario
A wrapper ORs STGM_TRANSACTED and a provider-only direct-mode flag, producing a combination the compound-file implementation cannot honor. Record the decisive state for it and verify recovery on a fresh object or request generation.
Difference from related HRESULTs
STG_E_INVALIDPARAMETER covers any bad argument; it narrows the defect to a flag field Tests and telemetry should preserve that boundary for it.
Developer and administrator guidance
Developers handling it should make object lifetime and state transitions explicit, preserve the native HRESULT, and keep cleanup paths safe when initialization or output is partial. Exercise direct and transacted modes, read-only and writable paths, cancellation, malformed input, and cleanup after partial output.
Administrators should repair the component owning STGM, commit, enumeration, or provider-specific flags passed to a storage API as a versioned unit instead of copying arbitrary DLLs. Repair for it should target only the evidence-backed component, provider, document, device, or configuration.
References
- Microsoft: COM error codes for STG and RPC
- Microsoft: Structured Storage
- Microsoft: IStorage
- Microsoft: IStream
Looking for a different code? Search another status or error code.