17.6 Copying Print Settings Between Drivers

To copy print settings from one driver to another, follow these steps:

1.Copy the first driver's DEVMODE structure by using the steps outlined in Section 17.4.2, “Retrieving a Copy of the Print Settings.”

2.Delete the device-specific information in the output DEVMODE structure by setting the dmDriverVersion and dmDriverExtra members to zero.

3.Determine the size of the buffer required for the DEVMODE structure for the second printer by calling the ExtDeviceMode function with the fwMode parameter set to zero and all other parameters set to information specific to the second printer.

4.Copy the DEVMODE structure produced in steps 1 and 2 to the buffer allocated in step 3. It is not necessary to copy the device-specific information to the buffer.

5.Free the buffer allocated in step 1.

6.Change the dmDeviceName member of the new DEVMODE structure to the name of the second device.

7.Call the second driver's ExtDeviceMode function, including the following information in the parameters:

Parameter Value

lpdmInput A pointer to the buffer that contains the altered DEVMODE structure
lpdmOutput A pointer to the output buffer
fwMode DM_MODIFY | DM_COPY

The second driver then places a valid, complete DEVMODE structure in the output buffer. The output structure reflects the device-independent settings your application copied from the first driver, but contains the second driver's device-specific information.