DeviceCapabilities

The DeviceCapabilities function retrieves the capabilities of a printer device driver.

DWORD DeviceCapabilities(
  LPCTSTR pDevice,    // pointer to a printer-name string
  LPCTSTR pPort,      // pointer to a port-name string
  WORD fwCapability,  // device capability to query
  LPTSTR pOutput,     // pointer to the output
  CONST DEVMODE *pDevMode 
                      // pointer to structure with device data
);
 

Parameters

pDevice
Pointer to a null-terminated string that contains the name of the printer. Note that this is the name of the printer, not of the printer driver.
pPort
Pointer to a null-terminated string that contains the name of the port to which the device is connected, such as "LPT1".
fwCapability
Specifies the capabilities to query. This parameter can be one of the following values:
Value Meaning
DC_BINADJUST Windows 95: Retrieves the page positioning for the paper source specified in the DEVMODE structure pointed to by pdevMode. The return value can be one of the following:
DCBA_FACEUPNONE
DCBA_FACEUPCENTER
DCBA_FACEUPLEFT
DCBA_FACEUPRIGHT
DCBA_FACEDOWNNONE
DCBA_FACEDOWNCENTER
DCBA_FACEDOWNLEFT
DCBA_FACEDOWNRIGHT
Windows 98: Not supported
DC_BINNAMES Copies an array containing a list of the names of the paper bins. This array is in the form char PaperNames[cBinMax][cchBinName] where cchBinName is 24. If the pOutput parameter is NULL, the return value is the number of bin entries required. Otherwise, the return value is the number of bins copied.
DC_BINS Retrieves a list of available bins. The function copies the list to the pOutput parameter as a WORD array. If pOutput is NULL, the function returns the number of supported bins to allow the application the opportunity to allocate a buffer with the correct size. For more information about these bins, see the description of the dmDefaultSource member of the DEVMODE structure.
DC_COPIES Returns the number of copies the device can print.
DC_DRIVER Returns the version number of the printer driver.
DC_DATATYPE_PRODUCED Windows 95: The return value is the number of datatypes supported by the printer driver. If the function returns -1, the driver understands the "RAW" datatype only. The names of the supported datatypes are copied to an array. Use the names in the DOCINFO structure when calling the StartDoc function to specify the datatype.

Windows 98: Not supported.

DC_DUPLEX Returns the level of duplex support. The function returns 1 if the printer is capable of duplex printing. Otherwise, the return value is zero.
DC_EMF_COMPLIANT Windows 95: Determines if a printer driver supports enhanced metafile (EMF). A return value of 1 means the driver supports EMF. A return value of -1 means that the driver does not support EMF.

Windows 98: Not supported.

DC_ENUMRESOLUTIONS Returns a list of available resolutions. If pOutput is NULL, the function returns the number of available resolution configurations. Resolutions are represented by pairs of LONG integers representing the horizontal and vertical resolutions (specified in dots per inch).
DC_EXTRA Returns the number of bytes required for the device-specific portion of the DEVMODE structure for the printer driver.
DC_FIELDS Returns the dmFields member of the printer driver's DEVMODE structure. The dmFields member indicates which members in the device-independent portion of the structure are supported by the printer driver.
DC_FILEDEPENDENCIES Returns a list of files that also need to be loaded when a driver is installed. If the pOutput parameter is NULL, the function returns the number of files. Otherwise, pOutput points to an array of filenames in the form char[chFileName, 64]. Each filename is a null-terminated string.
DC_MAXEXTENT Returns a POINTS structure that contains the maximum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can specify. The x member of the POINTS structure contains the maximum dmPaperWidth value, and the y member contains the maximum dmPaperLength value.
DC_MINEXTENT Returns a POINTS structure that contains the minimum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can specify. The x member of the POINTS structure contains the minimum dmPaperWidth value, and the y member contains the minimum dmPaperLength value.
DC_ORIENTATION Returns the relationship between portrait and landscape orientations for a device, in terms of the number of degrees that portrait orientation is rotated counterclockwise to produce landscape orientation. The return value can be one of the following:
0 No landscape orientation.
90 Portrait is rotated 90 degrees to produce landscape.
270 Portrait is rotated 270 degrees to produce landscape.
DC_PAPERNAMES Retrieves a list of supported paper names (for example, Letter or Legal). If the pOutput parameter is NULL, the function returns the number of paper sizes available. Otherwise, pOutput points to an array for the paper names in the form char[cPaperNames, 64]. Each paper name is a null-terminated string.
DC_PAPERS Retrieves a list of supported paper sizes. The function copies the list to pOutput as a WORD array and returns the number of entries in the array. If pOutput is NULL, the function returns the number of supported paper sizes to allow the application the opportunity to allocate a buffer with the correct size. For more information on paper sizes, see the description of the dmPaperSize member of the DEVMODE structure.
DC_PAPERSIZE Copies the dimensions of all supported paper sizes, in tenths of a millimeter, to an array of POINT structures pointed to by the pOutput parameter. The width (x-dimension) and length (y-dimension) of a paper size are returned as if the paper were in the DMORIENT_PORTRAIT orientation.
DC_SIZE Returns the dmSize member of the printer driver's DEVMODE structure.
DC_TRUETYPE Retrieves the abilities of the driver to use TrueType fonts. For DC_TRUETYPE, the pOutput parameter should be NULL. The return value can be one or more of the following:
DCTT_BITMAP Device can print TrueType fonts as graphics.
DCTT_DOWNLOAD Device can down-load TrueType fonts.
DCTT_DOWNLOAD_
OUTLINE
Windows 95 and Windows 98: Device can download outline TrueType fonts.
DCTT_SUBDEV Device can substitute device fonts for TrueType fonts.
DC_VERSION Returns the specification version to which the printer driver conforms.

pOutput
Pointer to an array of bytes. The format of the array depends on the setting of the fwCapability parameter. If pOutput is zero, DeviceCapabilities returns the number of bytes required for the output data.
pDevMode
Pointer to a DEVMODE structure. If this parameter is NULL, DeviceCapabilities retrieves the current default initialization values for the specified printer driver. Otherwise, the function retrieves the values contained in the structure to which pDevMode points.

Return Values

If the function succeeds, the return value depends on the setting of the fwCapability parameter.

If the function fails, the return value is –1.

Windows NT: To get extended error information, call GetLastError.

Remarks

In 16-bit versions of Windows, the DeviceCapabilities function was implemented in the printer driver and you needed to call the LoadLibrary and GetProcAddress functions to get a pointer to the function. This is no longer necessary, because DeviceCapabilities is part of the Win32 API. You should not call LoadLibrary on the printer driver.

The DEVMODE structure pointed to by the pDevMode parameter may be obtained by calling the DocumentProperties function.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in wingdi.h.
  Import Library: Use winspool.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

Device Contexts Overview, Device Context Functions, DEVMODE, DocumentProperties, GetDeviceCaps, GetProcAddress, LoadLibrary, POINT