int ExtDeviceMode(hWnd,hDriver,lpDevModeOutput,lpDeviceName,lpPort,lpDevModeInput,lpProfile,wMode)
This function retrieves or modifies device initialization information for a given printer driver, or displays a driver-supplied dialog box for configuring the printer driver. Printer drivers that support device initialization by applications export this ExtDeviceMode so that applications can call it.
Parameter | Type/Description |
hWnd | HWND Identifies a window. If the application calls ExtDeviceMode to display a dialog box, the specified window is the parent of the dialog box. | ||
hDriver | HANDLE Identifies the device-driver module. The GetModuleHandle function or LoadLibrary function returns a module handle. | ||
lpDevModeOutput | DEVMODE FAR * Points to a DEVMODE data structure. The driver writes the initialization information supplied in the lpDevModeInput parameter to this structure. | ||
lpDeviceName | LPSTR Points to a null-terminated character string that contains the name of the printer device, such as “PCL/HP LaserJet.” | ||
lpPort | LPSTR Points to a null-terminated character string that contains the name of the port to which the device is connected, such as LPT1:. | ||
lpDevModeInput | DEVMODE FAR * Points to a DEVMODE data structure that supplies initialization information to the printer driver. | ||
lpProfile | LPSTR Points to a null-terminated string that contains the name of the initialization file which initialization information is recorded in and read from. If this parameter is NULL, WIN.INI is the default. | ||
wMode | WORD Specifies a mask of values which determine the types of operations the function will perform. If wMode is zero, ExtDeviceMode returns the number of bytes required by the printer device driver's DEVMODE structure. Otherwise, wMode must be one or more of the following values: | ||
Value | Meaning | ||
DM_COPY | Writes the printer driver's current print settings to the DEVMODE data structure identified by lpDevMode-Output. The calling application must allocate a buffer sufficiently large to contain the information. If this bit is clear, lpDevModeOutput can be NULL. | ||
DM_MODIFY | Changes the printer driver's current print settings to match the partial initialization data in the DEVMODE data structure identified by lpDevModeInput before prompting, copying, or updating. | ||
DM_PROMPT | Presents the printer driver's Print Setup dialog box and then changes the current print settings to those the user specifies. | ||
DM_UPDATE | Writes the printer driver's current print settings to the printer environment and the WIN.INI initialization file. |
If the wMode parameter is zero, the return value is the size of the DEVMODE data structure required to contain the printer driver initialization data. If the function displays the initialization dialog box, the return value is either IDOK or IDCANCEL, depending on
which button the user selected. If the function does not display the dialog box and was successful, the return value is IDOK. The return value is less than zero if the function failed.
The ExtDeviceMode function is actually part of the printer's device driver, and not part of GDI. To call this function, the application must include the DRIVINT.H file, load the printer device driver, and retrieve the address of the function by using the GetProc-Address function. The application can then use the address to set up the printer.
An application can set the wMode parameter to DM_COPY to obtain a DEVMODE data structure filled in with the printer driver's initialization data. The application can then pass this data structure to the CreateDC function to set a private environment for the printer device context.