Enumerating Printers

pruebens

Well-known member
Joined
Nov 21, 2002
Messages
71
I have coded a ASP form for inventory purposes and want to get the current installed printers for a workstation. What I have found out is that I need to do this via a cookie (due to ASP constraints) and can get close but since Im such a n00b Im stuck on something. First here is my code:

Code:
      If Request.Browser.Cookies Then
                Response.Cookies("Printers").Expires = DateTime.Now
                Dim cookPrint As New HttpCookie("Printers", Now.ToString)
                cookPrint("PrinterName") = printersettings.installedprinters
                cookPrint.Expires = DateTime.Now.AddDays(1)
                Response.Cookies.Add(cookPrint)
            End If
            

            Dim cookPrintInfo As HttpCookie = Request.Cookies("Printers")
            print = cookPrintInfo("PrinterName")
This all works fine IF I change the cookPrint("PrinterName") to a static name (Ie = "Printer"). But if I try to use the above line and get the installed printers I get the following error:

Value of type system.drawing.printing.printersettings.stringcollection cannot be converted to String


Im obviously leaving something out and I hope someone can point out what I need to do. Thanks.
 
PrinterSettings.InstalledPrinters is a string collection. You have to iterate thru it to access its values:

Dim strPrinter As String
For Each strPrinter In PrinterSettings.InstalledPrinters
-Manipulate strPrinter here...
Next
 
That will only get me the printers that are installed on the server and not on the client though I believe.

It looks like Im going to have to do an active X control.
 
That is true since code above will be running on the server-side. Yup, the activex control may be your route here.
 
Back
Top