Changing the default printer

  • Thread starter Thread starter Stephen
  • Start date Start date
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
 
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
 
Back
Top