| Previous | Next |
| DV_E_FORMATETC | DV_E_STGMEDIUM |
DV_E_DVTARGETDEVICE
Invalid DVTARGETDEVICE structure
DV_E_DVTARGETDEVICE is HRESULT 0x80040065. It means OLE data transfer rejected the DVTARGETDEVICE structure referenced by FORMATETC::ptd. The structure is a variable-length buffer that uses offsets, not process-local pointers, to identify driver, device, port, and optional DEVMODE data.
What to check
- Validate
tdSizeagainst the complete allocated buffer. - Check
tdDriverNameOffset,tdDeviceNameOffset,tdPortNameOffset, andtdExtDevmodeOffset; every nonzero offset must point inside the same buffer. - Do not copy absolute pointers into the descriptor. Rebuild offsets after serialization or cross-process transfer.
- Confirm the target printer/device and
DEVMODEdata are still valid for the current operation.
Capture the failing FORMATETC, total DVTARGETDEVICE buffer length, and all offsets before freeing the descriptor. If no target device is required, compare the operation with ptd = NULL rather than inventing a placeholder descriptor.
Related results
DV_E_DVTARGETDEVICE_SIZE specifically indicates an invalid size. DV_E_DVTARGETDEVICE covers the target-device descriptor as a whole, including malformed offsets or device data.
Example
A data object serializes a DVTARGETDEVICE by copying pointer values from another process. Rebuilding the descriptor as one self-contained buffer with validated offsets makes the target-device data portable.
References
Looking for a different code? Search another status or error code.
