Changing the default printer

S

Stephen

Greetings folks....

I have a app that needs to have the printer default changed ( if not using
the default) prior to anything else happening in the program and when the
program terminates, to set the original default back... Any idea's?

steve
 
K

Ken Tucker [MVP]

Hi,


Use the wmi for that. The win32_printer class has the
setdefaultprinter method.


' Add a Reference to System.Management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

strOut = String.Format("Name {0} ", mo("Name"))

Trace.WriteLine(strOut)

mo.InvokeMethod("SetDefaultPrinter", Nothing)

Next



Ken

------------------------

Greetings folks....

I have a app that needs to have the printer default changed ( if not using
the default) prior to anything else happening in the program and when the
program terminates, to set the original default back... Any idea's?

steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top