17.2 How Windows Manages Print Settings

When your application prints, it uses a printer device context that it created by using the CreateDC function. When creating a device context for a printer, the application specifies the printer driver and name, the output port, and, optionally, print settings for that driver. These settings are device-specific, applying to a specific printer and printer driver. Because the exact settings can differ from printer to printer, ensure that your application supplies the specific information that each printer driver requires.

When an application calls CreateDC to create a printer device context in preparation for printing, Windows creates the device context by using the first print settings it can find. It searches for print settings in the following order:

1.Windows first uses the print settings (if any) that the application passed by using the DEVMODE structure pointed to by the lpvInitData parameter of the CreateDC function.

2.If the application did not pass any print settings when calling CreateDC, Windows searches for the print settings that the printer driver stored most recently in memory.

3.If the printer driver has not yet stored any print settings in memory, the printer driver searches for the print settings in the WIN.INI file. If WIN.INI does not contain complete print settings for this printer and port, the printer driver fills any gaps by using its own built-in default settings.

Your application has the most control over print settings if you specify settings when calling the CreateDC function. If you do specify print settings by using CreateDC, Windows uses those settings instead of other settings that may be available from the driver or from WIN.INI.