1

Done quite a lot of searching around this one and so far I've only managed to get printer preferences, not properties.

I'd like to invoke the actual printer properties window, the one where you can set security data for the printer directly from code.

I've got the printer name etc, just need to be able to display it's properties

Any help would be most appreciated!

So far I've tried a few different implementations, the most common involving winspool.Drv which shows the actual printer properties window (often a custom window from the manufacturer)

Example:

Printer Properties Dialog

Daniel Frear
  • 1,459
  • 14
  • 22
  • 1
    Are you talking about showing a [print dialog](http://msdn.microsoft.com/en-us/library/system.windows.controls.printdialog.aspx)? You can use it to let the user create a PrintTicket which contains all the configuration info for a printer. Problem is that the "accept" button says "print." [Tried to figure that one out](http://stackoverflow.com/questions/2668731) but never got it working. –  Mar 20 '12 at 15:02
  • No I don't think it's the print dialog - I'm not actually trying to print anything, just access the dialog to set security as part of an application. Will add an example image – Daniel Frear Mar 20 '12 at 15:05
  • 1
    Did you try using something like `rundll32 printui.dll,PrintUIEntry /p /n "printernamegoeshere"`? – M.Babcock Mar 20 '12 at 15:10
  • Why did you blur the model number of your brother MFC-9120CN? – Scott Chamberlain Mar 20 '12 at 15:11
  • 1
    Spot on! That will do me fine – Daniel Frear Mar 20 '12 at 15:12
  • 1
    @ScottChamberlain - I didnt, it's an image off the Brother Website (I assume they blur it so as not to cause confusion as they use the same image for multiple printers) – Daniel Frear Mar 20 '12 at 15:13

3 Answers3

6

You can launch the printer properties dialog using something like

rundll32 printui.dll,PrintUIEntry /p /n "printernamegoeshere"

with the Process class.

M.Babcock
  • 18,753
  • 6
  • 54
  • 84
3

In fact there is a native API for invoking that window - call OpenPrinter and then call PrinterProperties.

From C# you will have to go the p/invoke route...

Yahia
  • 69,653
  • 9
  • 115
  • 144
0

To launch the printer property using the Process class and without showing the CMD window, use the following code:

string printerName = "Microsoft Print to PDF"; // Change this with your printer name 
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new 
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C rundll32 printui.dll,PrintUIEntry /p /n \"" + printerName + "\"";
process.StartInfo = startInfo;
process.Start();