Syntax

Parameters

The item to be returned. This parameter can be one of the following values.

Index

Meaning

DRIVERVERSION

The device driver version.

TECHNOLOGY

Device technology. It can be any one of the following values.

DT_PLOTTERVector plotter

DT_RASDISPLAYRaster display

DT_RASPRINTERRaster printer

DT_RASCAMERARaster camera

DT_CHARSTREAMCharacter stream

DT_METAFILEMetafile

DT_DISPFILEDisplay file

If the hdc parameter is a handle to the DC of an enhanced metafile, the device technology is that of the referenced device as specified to the CreateEnhMetaFile function. To determine whether it is an enhanced metafile DC, use the GetObjectType function.

HORZSIZE

Width, in millimeters, of the physical screen.

VERTSIZE

Height, in millimeters, of the physical screen.

HORZRES

Width, in pixels, of the screen; or for printers, the width, in pixels, of the printable area of the page.

VERTRES

Height, in raster lines, of the screen; or for printers, the height, in pixels, of the printable area of the page.

LOGPIXELSX

Number of pixels per logical inch along the screen width. In a system with multiple display monitors, this value is the same for all monitors.

LOGPIXELSY

Number of pixels per logical inch along the screen height. In a system with multiple display monitors, this value is the same for all monitors.

BITSPIXEL

Number of adjacent color bits for each pixel.

PLANES

Number of color planes.

NUMBRUSHES

Number of device-specific brushes.

NUMPENS

Number of device-specific pens.

NUMFONTS

Number of device-specific fonts.

NUMCOLORS

Number of entries in the device's color table, if the device has a color depth of no more than 8 bits per pixel. For devices with greater color depths, 1 is returned.

ASPECTX

Relative width of a device pixel used for line drawing.

ASPECTY

Relative height of a device pixel used for line drawing.

ASPECTXY

Diagonal width of the device pixel used for line drawing.

PDEVICESIZE

Reserved.

CLIPCAPS

Flag that indicates the clipping capabilities of the device. If the device can clip to a rectangle, it is 1. Otherwise, it is 0.

SIZEPALETTE

Number of entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.

NUMRESERVED

Number of reserved entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.

COLORRES

Actual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.

PHYSICALWIDTH

For printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-x11-inch paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.

PHYSICALHEIGHT

For printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.

PHYSICALOFFSETX

For printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the leftmost 0.25-inch of paper, has a horizontal physical offset of 150 device units.

PHYSICALOFFSETY

For printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the topmost 0.5-inch of paper, has a vertical physical offset of 300 device units.

VREFRESH

For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).

A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use display functions such as ChangeDisplaySettings.

SCALINGFACTORX

Scaling factor for the x-axis of the printer.

SCALINGFACTORY

Scaling factor for the y-axis of the printer.

BLTALIGNMENT

Preferred horizontal drawing alignment, expressed as a multiple of pixels. For best drawing performance, windows should be horizontally aligned to a multiple of this value. A value of zero indicates that the device is accelerated, and any alignment may be used.

SHADEBLENDCAPS

Value that indicates the shading and blending capabilities of the device. See Remarks for further comments.

SB_CONST_ALPHAHandles the SourceConstantAlpha member of the BLENDFUNCTION structure, which is referenced by the blendFunction parameter of the AlphaBlend function.

Return value

When nIndex is BITSPIXEL and the device has 15bpp or 16bpp, the return value is 16.

Remarks

When nIndex is SHADEBLENDCAPS:

For a printer, GetDeviceCaps returns whatever the printer reports.

For a display device, all blending operations are available; besides SB_NONE, the only return values are SB_CONST_ALPHA and SB_PIXEL_ALPHA, which indicate whether these operations are accelerated.

On a multiple monitor system, if hdc is the desktop, GetDeviceCaps returns the capabilities of the primary monitor. If you want info for other monitors, you must use the multi-monitor APIs or CreateDC to get a HDC for the device context (DC) of a specific monitor.

Note Display1 is typically the primary monitor, but not always.

GetDeviceCaps provides the following six indexes in place of printer escapes.

Index

Printer escape replaced

PHYSICALWIDTH

GETPHYSPAGESIZE

PHYSICALHEIGHT

GETPHYSPAGESIZE

PHYSICALOFFSETX

GETPRINTINGOFFSET

PHYSICALOFFSETY

GETPHYSICALOFFSET

SCALINGFACTORX

GETSCALINGFACTOR

SCALINGFACTORY

GETSCALINGFACTOR

NoteGetDeviceCaps reports info that the display driver provides. If the display driver declines to report any info, GetDeviceCaps calculates the info based on fixed calculations. If the display driver reports invalid info, GetDeviceCaps returns the invalid info. Also, if the display driver declines to report info, GetDeviceCaps might calculate incorrect info because it assumes either fixed DPI (96 DPI) or a fixed size (depending on the info that the display driver did and didn’t provide). Unfortunately, a display driver that is implemented to the Windows Display Driver Model (WDDM) (introduced in Windows Vista) causes GDI to not get the info, so GetDeviceCaps must always calculate the info.