Re: Set default printer for the machine
From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 10/22/04
- Next message: Z D: "Re: Confusion: Threading & COM Interop"
- Previous message: Tim Bücker: "Read line in textfile"
- In reply to: Willy Denoyette [MVP]: "Re: Set default printer for the machine"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 22 Oct 2004 13:27:22 -0400
Fantastic !!
-- - Sahil Malik http://www.dotnetjunkies.com/weblog/sahilmalik Please reply to the newsgroups instead of email so everyone can benefit from your reply. "Willy Denoyette [MVP]" <willy.denoyette@pandora.be> wrote in message news:OV%23Oac1tEHA.2804@TK2MSFTNGP14.phx.gbl... > Using System.Management and WMI. > > public static void Main() { > if (SetAsDefaultPrinter("Printerdev") != 0) > { > Console.WriteLine("Failed to set default printer"); > } > } > static int SetAsDefaultPrinter(string printerDevice) > { > int ret = 0; > string path = "win32_printer.DeviceId='" + printerDevice + "'"; > using (ManagementObject printer = new ManagementObject(path)) > { > ManagementBaseObject outParams = > printer.InvokeMethod("SetDefaultPrinter", > null, null); > ret = (int)(uint)outParams.Properties["ReturnValue"].Value; > } > return ret; > } > > Willy. > > "Vivek" <vivek@nospam.com> wrote in message > news:u8b415xtEHA.3832@TK2MSFTNGP10.phx.gbl... > > Hi People, > > > > I want to change the default printer of the machine. I tried this. > > > > PrinterSettings pdDefault = new PrinterSettings(); > > > > pdDefault.PrinterName = "PrinterName"; > > > > It did not work. Please guide. > > > > > > > > Thanks > > > > > >
- Next message: Z D: "Re: Confusion: Threading & COM Interop"
- Previous message: Tim Bücker: "Read line in textfile"
- In reply to: Willy Denoyette [MVP]: "Re: Set default printer for the machine"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|