#include <print.h> |
DWORD DeviceCapabilities(lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm) | |||||
LPSTR lpszDevice; | /* address of device-name string | */ | |||
LPSTR lpszPort; | /* address of port-name string | */ | |||
WORD fwCapability; | /* device capability to query | */ | |||
LPSTR lpszOutput; | /* address of the output | */ | |||
LPDEVMODE lpdm; | /* address of structure with device data | */ |
The DeviceCapabilities function retrieves the capabilities of the printer device driver.
lpszDevice
Points to a null-terminated string that contains the name of the printer device, such as PCL/HP LaserJet.
lpszPort
Points 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_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 lpszOutput 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 lpszOutput parameter as a WORD array. If lpszOutput 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_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_ENUMRESOLUTIONS | Returns a list of available resolutions. If lpszOutput 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 fields 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 lpszOutput parameter is NULL, the function returns the number of files. Otherwise, lpszOutput points to an array of filenames in the form char[chFileName, 64]. Each filename is a null-terminated string. |
DC_MAXEXTENT | Returns a POINT structure containing the maximum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can specify. |
DC_MINEXTENT | Returns a POINT structure containing the minimum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can specify. |
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: |
Value | Meaning |
0 | No landscape orientation. |
90 | Portrait is rotated 90 degrees to produce landscape. (For example, Hewlett-Packard PCL printers.) |
270 | Portrait is rotated 270 degrees to produce landscape. (For example, dot-matrix printers.) |
DC_PAPERNAMES | Retrieves a list of supported paper names—for example, Letter or Legal. If the lpszOutput parameter is NULL, the function returns the number of paper sizes available. Otherwise, lpszOutput 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 lpszOutput as a WORD array and returns the number of entries in the array. If lpszOutput 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 lpszOutput 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. The return value can be one or more of the following: | ||
Value | Meaning |
DCTT_BITMAP | Device is capable of printing TrueType fonts as graphics. (For example, dot-matrix and PCL printers.) |
DCTT_DOWNLOAD | Device is capable of downloading TrueType fonts. (For example, PCL and PostScript printers.) |
DCTT_SUBDEV | Device is capable of substituting device fonts for TrueType fonts. (For example, PostScript printers.) |
For DC_TRUETYPE, the lpszOutput parameter should be NULL. | |
DC_VERSION | Returns the specification version to which the printer driver conforms. |
lpszOutput
Points to an array of bytes. The format of the array depends on the setting of the fwCapability parameter. If lpszOutput is zero, DeviceCapabilities returns the number of bytes required for the output data.
lpdm
Points 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 lpdm points.
The DEVMODE structure has the following form:
#include <print.h>
typedef struct tagDEVMODE { /* dm */
char dmDeviceName[CCHDEVICENAME];
UINT dmSpecVersion;
UINT dmDriverVersion;
UINT dmSize;
UINT dmDriverExtra;
DWORD dmFields;
int dmOrientation;
int dmPaperSize;
int dmPaperLength;
int dmPaperWidth;
int dmScale;
int dmCopies;
int dmDefaultSource;
int dmPrintQuality;
int dmColor;
int dmDuplex;
int dmYResolution;
int dmTTOption;
} DEVMODE;
For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.
The return value, if the function is successful, depends on the setting of the fwCapability parameter. The return value is –1 if the function fails.
This function is supplied by the printer driver. To use the DeviceCapabilities function, an application must retrieve the address of the function by calling the LoadLibrary and GetProcAddress functions, and it must include the PRINT.H file.
DeviceCapabilities is not supported by all printer drivers. If the GetProcAddress function returns NULL, DeviceCapabilities is not supported.