TimRude Posted December 30, 2022 Share Posted December 30, 2022 When using the _WinAPI_PrintDlg or _WinAPI_PrintDlgEx functions to display a print dialog, is there a way to take the DevMode settings specified by the user, save them somewhere, and then apply them as the default settings for that printer (i.e. make them stick)? I don't mean retrieving the various settings one by one, such as Paper Size, Paper Tray, etc. I mean the whole DevMode of settings for the printer as one chunk. Some printers have private settings that can only be set by their printer preferences dialog and there's no way to pull the information on those settings from the system. Thus the desire to grab the whole batch of settings as one chunk and save it as a file, and then be able to assign that chunk of settings as the new default for that printer. Here's what I am trying to accomplish: I have a separate app written in VB6 that needs to be able to set the media type for the printer. This media type specifies the kind of paper being printed on, such as 'thin paper', 'standard paper', 'thick paper', 'envelope', etc. The trouble is, there is not a reliable standard for this setting, and each printer driver manufacturer pretty much does it's own thing (if it supports a setting like this at all). And while there is a dmMediaType field in the DevMode structure, many printer drivers simply don't use it. Instead they apparently set this within the private driver data that follows the public structure members, making it impossible to programmatically set it in code in a way that works for every printer. The only way to properly set it is to use the printer driver's proprietary preferences dialog, such as this example: So what I'd like to do is: (1) Let the user do a 1-time setup of a specific printer using an AutoIt print dialog (and the driver preferences dialog accessed through it) to create a DevMode of desired settings, and then save this to a file for re-use later. (2) When the user gets ready to print from the VB6 app, it first runs the AutoIt app to save the default DevMode settings for the printer (so I can put them back when I'm finished). (3) Then the AutoIt app applies the custom DevMode settings that were saved in step 1 to make these the new default settings for the printer, and signals back to the VB6 app to go ahead and print. (4) Then the VB6 app prints the job. The VB6 printer object always starts with loading the driver's saved default settings, so if I successfully changed the default settings to include the desired Media Type before starting the print job, the VB6 app will then use it. (5) As soon as the VB6 app completes the job, it will notify the AutoIt app to restore the original DevMode settings that were saved in step 2 to restore the printer's setting back to their original defaults. I can handle the interactions between the VB6 app and an Auto-It app. But I don't know how (or of it's even possible) to save the entire DevMode of settings to a file, and to then use those saved settings to change the default driver settings for all apps. Any thoughts from the experts? Link to comment Share on other sites More sharing options...
Solution rudi Posted January 2, 2023 Solution Share Posted January 2, 2023 Hello, you can use for printserver shared printer objects GPOs to distribute the printer settings. As well you can use the command line to handle (almost?) all the settings regarding printer configuration. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui Google: rundll32 printui.dll Regards, Rudi. TimRude 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
TimRude Posted January 3, 2023 Author Share Posted January 3, 2023 @rudi Thanks for that pointer! I'm doing some experimenting with it now. Much obliged! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now