473,772 Members | 3,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting the default printer

Hello,
I have the following code that sets the default printer using the WMI
(windows management system).

' 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
If CType(mo("Name" ), String) = Me.cboPrinter.T ext Then
mo.InvokeMethod ("SetDefaultPri nter", Nothing)
Exit For
End If
Next
This works fine, however, how do I get the default printer. How do I know
what methods Invokemethod accepts? Intellisense doesn't tell me.

Geri.
Nov 21 '05 #1
1 1449
Hi,

You need to look up the wmi class to get a list of methods.
mo("Default") will return true if the printer is the default printer.

http://msdn.microsoft.com/library/de...32_printer.asp
Ken
-------------------

"Geraldine Hobley" <Ge************ *@discussions.m icrosoft.com> wrote in
message news:40******** *************** ***********@mic rosoft.com...
Hello,
I have the following code that sets the default printer using the WMI
(windows management system).

' 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
If CType(mo("Name" ), String) = Me.cboPrinter.T ext Then
mo.InvokeMethod ("SetDefaultPri nter", Nothing)
Exit For
End If
Next
This works fine, however, how do I get the default printer. How do I know
what methods Invokemethod accepts? Intellisense doesn't tell me.

Geri.
Nov 21 '05 #2

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

Similar topics

1
13026
by: Pablo | last post by:
Friends, how can i get the name of the default printer??. I'm working with winforms. VB,C#, nevermind. Thanks a lot Pablo
0
2592
by: Esmee | last post by:
Hi there, I have created an Access 2002 db which contains several reports. Some reports need to be printed on a Laserjet and others on a Labelprinter. One of my clients wants to be able to print the same reports to 3 different laserjets and to 3 different labelprinters. (They work with the db on 3 different units each with their own Laserjet and Labelprinter) For each unit there is a copy of all the reports. The client can make a unit...
3
3639
by: Geraldine Hobley | last post by:
Hello, How would you get and set the current default printer by using the system.drawing.printing class or any other class. Regards Geri
3
17185
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
1616
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
5469
by: i8mypnuts | last post by:
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been changed, Access 2003 still directs the report to the former default printer. Access 2003 picks up the new default printer setting only after I have reopened the application. I have checked the default printer setting in the OS control panel and the...
5
2007
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
9086
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 =
3
4288
by: brianflannery | last post by:
Greetings all! My problem is this. I've installed a new printer on my computer. This is the "default printer" for access. Now, some of my reports, which were working fine with the old printer, are now showing up with an odd view (very enlarged) in preview. If I go to page setup, and choose specific printer to then look at the paper size listed in my default printer, it shows Hegaki Card 100mmX148mm instead of letter. It seems as...
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10104
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
10038
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
8934
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
7460
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...
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.