473,626 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting and setting the default printer

Hello,
How would you get and set the current default printer by using the
system.drawing. printing class or any other class.

Regards
Geri
Nov 21 '05 #1
3 3627
Hi,
Use the wmi for that. The win32_printer class has the
setdefaultprint er method.
' Add a Reference to System.Manageme nt

Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("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 ("SetDefaultPri nter", Nothing)

Next

Ken

------------------------
"Geraldine Hobley" <Ge************ *@discussions.m icrosoft.com> wrote in
message news:76******** *************** ***********@mic rosoft.com...
Hello,
How would you get and set the current default printer by using the
system.drawing. printing class or any other class.

Regards
Geri
Nov 21 '05 #2
"Geraldine Hobley" <Ge************ *@discussions.m icrosoft.com> schrieb:
How would you get and set the current default printer by using the
system.drawing. printing class or any other class.


Either use WMI or take a look at this article:

HOWTO: Retrieve and Set the Default Printer in Windows
<URL:http://support.microso ft.com/?scid=kb;EN-US;246772>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Hi ken,
Thanx for the help, that allows me to set the default printer
perfectly, however how do I retrieve the default printer, as I need to
display this.

Regards
Geri.

"Ken Tucker [MVP]" wrote:
Hi,
Use the wmi for that. The win32_printer class has the
setdefaultprint er method.
' Add a Reference to System.Manageme nt

Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("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 ("SetDefaultPri nter", Nothing)

Next

Ken

------------------------
"Geraldine Hobley" <Ge************ *@discussions.m icrosoft.com> wrote in
message news:76******** *************** ***********@mic rosoft.com...
Hello,
How would you get and set the current default printer by using the
system.drawing. printing class or any other class.

Regards
Geri

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10588
by: Stephen Barrett | last post by:
I am doing word automation with Word 2003. Everything works great except for one thing. When I set the word object's ActivePrinter to a different printer, it changes the system default. I looked for help on MS site and they say it is a known issue. The work around is to use WordBasic commands like as follows. ------------------------------------ MORE INFORMATION To select a new printer without having Word change the default system...
4
4727
by: Umesh | last post by:
Hi all I am trying to change the printer(like paper source ,etc) setting in C#. But i am unable to do it. I am not sure how to do it. should i have to use WIN API like Openprinter , getprinter , setprinter . I did try with PrinterSetting.setHDevMode but it does not work. Its their is a simple way to change printersetting. thanks umesh.
0
1713
by: emde | last post by:
I am trying to set the default system printer and have got as far as listing the installed printers using PrinterSettings.InstalledPrinters. Anyone know how change the default printer? It needs to change the system printer, not just the printer for this application. I assume I must tap into winspool.dll some how. tia
1
1446
by: Geraldine Hobley | last post by:
Hello, I have the following code that sets the default printer using the WMI (windows management system). ' 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
3
17127
by: Panos | last post by:
Hi, is there a way that i could get the default printer of the system? I'm using VB.net 2001. There is a function in SDK called "GetDefaultPrinter", but i don't understand how to use it.
0
1608
by: Karthick_Microsoft | last post by:
Actually, in my ASP.Net application, i have a requirement of automatically changing the default printer. I did a OCX using VB and put it on the web page. The client machines do not have local printers but network printers (they have been mapped using Local Port pointing to \\machine\printer - this was suggested in a topic - for a reason that a network printer can be given a friendly name) - But when I click on Print from the browser...
1
6109
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As PRINTER_DEFAULTS Dim pinfo2 As PRINTER_INFO_2 Dim pinfo8 As PRINTER_INFO_8 Dim pinfo9 As PRINTER_INFO_9 Dim dm As DEVMODEW Dim yDevModeData() As Byte
5
2002
by: Glenn | last post by:
Hi We have a ASP.net app which calls into a web service which allow users to print stuff. At the moment they have to specify the printer. Apparently this is too much for our users, so I was wondering if there's a way of getting the default printer from their user profile? TIA Glenn
13
9076
by: Mark Rae | last post by:
Hi, I have used the code below to return the default printer in 32-bit WinXP Pro, but now that I am running 64-bit Vista Business I'm getting an error: using System.Drawing.Printing; using (PrintDocument objPrintDocument = new PrintDocument()) { string strDefaultPrinter =
0
8205
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8644
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7206
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.