Win32_PrinterConfiguration

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Win32_PrinterConfiguration

Postposted on Tue Jun 09, 2009 8:00 am

Any pros here ever deal with this class? I can use it to query all my printers on the network from, say, VB.Net with no problem. But according to MS documentation its properties are readonly. I wrote a small program that will fill a dropdown with a few printers on the computer, then upon selected the printer, it will tell you it's properties such as if it is color or monochrome only, what it's current orientation is, etc.

The orientation is what I want to set programmatically, and it seems it sort of works. If I write out what the orientation is before anythign is set, it returns a "1" which is portrait. If I set it, and write it out again, it returns a "2" for landscape. However, if I go into my printer settings for that printer, it's still showing portrait, and it still prints portrait from my code.

Code: Select all
 Try
            Dim objWMIService = GetObject("winmgmts:\\.\root\cimv2")
            Dim colPrinters = objWMIService.ExecQuery("Select * from Win32_PrinterConfiguration") ' where Name = '\\\\SERVER\\PRINTER_NAME'")
            For Each objPrinter In colPrinters
                objPrinter.PageSettings.Landscape = True
                MsgBox(objPrinter.orientation)
            Next
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
Corsair 600T | ASUS P8P67 PRO | Intel 2500k @ 4.4Ghz | EVGA 560 TI | G.SKILL Ripjaws Series 8GB | Corsair HX650 650W
steelcity_ballin
Gerbilus Supremus
Silver subscriber
 
 
Posts: 11911
Joined: Mon May 26, 2003 5:55 am
Location: Pittsburgh PA

Re: Win32_PrinterConfiguration

Postposted on Tue Jun 09, 2009 6:06 pm

I expect that it is only setting the orientation property for that instance of the object. If you printed something with the "objPrinter" after changing the orientation, I expect it would be honored. However, it is not changing the printer default settings.

--SS
SecretSquirrel
Gerbil Jedi
Gold subscriber
 
 
Posts: 1704
Joined: Tue Jan 01, 2002 7:00 pm
Location: The Colony, TX (Dallas suburb)

Re: Win32_PrinterConfiguration

Postposted on Thu Jun 11, 2009 11:09 am

Well I believe you are correct, and I found a better solution. The PrintDocument object provides support for things of this nature, and actually has a fairly clean implementation. The difficulty then is "how do I tell the browser to print using the PrintDocument object?" Well I haven't gotten it working just yet but I believe that by using the graphics namespace I can draw the contents of the browser and then call that to print. Should work.
Corsair 600T | ASUS P8P67 PRO | Intel 2500k @ 4.4Ghz | EVGA 560 TI | G.SKILL Ripjaws Series 8GB | Corsair HX650 650W
steelcity_ballin
Gerbilus Supremus
Silver subscriber
 
 
Posts: 11911
Joined: Mon May 26, 2003 5:55 am
Location: Pittsburgh PA


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest

cron