473,383 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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.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
If CType(mo("Name"), String) = Me.cboPrinter.Text Then
mo.InvokeMethod("SetDefaultPrinter", 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 1433
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.microsoft.com> wrote in
message news:40**********************************@microsof t.com...
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
Win32_Printer")
moReturn = moSearch.Get

For Each mo In moReturn
If CType(mo("Name"), String) = Me.cboPrinter.Text Then
mo.InvokeMethod("SetDefaultPrinter", 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
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
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...
3
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
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
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...
1
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...
5
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...
13
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...
3
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.