IsValidDevmodeW function (winspool.h)

The print spooler's IsValidDevmode function verifies that the contents of a DEVMODE structure are valid.


BOOL IsValidDevmodeW(
  [in, optional] PDEVMODEW pDevmode,
                 size_t    DevmodeSize


[in, optional] pDevmode

Pointer to the DEVMODE structure to be validated.


Size, in bytes, of the buffer pointed to by pDevmode.

Return value

If the DEVMODE structure is valid, or if the function succeeds in repairing the structure to make it valid, the function returns TRUE. Otherwise, the function returns FALSE. The caller can obtain an error code by calling GetLastError.


Before using a DEVMODE structure obtained from a possibly unreliable source, a printer driver can call this function to verify that the structure is valid. This function validates only the public members of the DEVMODE structure. It does not check the private members of the structure.

The dmSize member of the DEVMODE structure specifies the size of the DEVMODE structure, not including any private, driver-specified data appended to the structure. The dmDriverExtra member specifies the size of the private data appended to the structure, if there is any. Callers should set DevModeSize to dmSize+dmDriverExtra only if they can guarantee that the input buffer size is at least that large.

This function does not require the caller to obtain elevated privileges.


Target Platform Desktop
Header winspool.h (include Winspool.h)
Library Winspool.lib
DLL Winspool.drv

See also