Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Dear Friends,

I am new in windows application.

I have made a Kiosk application for printing salary certificate and it has gone live.

Now they have asked some ammendments they are.
1) If the application gets closed for any reason it should automatically open again and user should not be able to do anything else.
2) If there is no paper in printer the user should be informed that no paper exist.
3) The machine is a touch screen some users interrupts the process by continously clicking and the application gets close, how to prevent this.

Please help if you have any idea in over coming these issues.

Thanks In Advance
Updated 18-Sep-12 22:46pm

1 solution

Here is one method to get the status and state of the printer (status includes the items you are looking for as well)

view source

Public Shared Function GetPrinterProperties() As Hashtable
Dim properties As Hashtable = New Hashtable()
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_Printer")

'now loop thorugh all the objects in the searcher
Dim obj As ManagementObject
For Each obj Function searcher.Get() As In
"Other", "Unknown", "Idle", "Printing", "WarmUp", "Stopped Printing", "Offline"
End Function

string() printerState = {"Paused","Error","Pending Deletion","Paper Jam","Paper Out","Manual Feed","Paper Problem", "Offline","IO Active","Busy","Printing",
"Output Bin Full","Not Available","Waiting", "Processing","Initialization","Warming Up","Toner Low","No Toner","Page Punt", "User Intervention Required",
"Out of Memory","Door Open","Server_Unknown","Power Save"

'now loop through all the properties
Dim data As PropertyData
For Each data In obj.Properties
'make sure we have the default printer
If CType(obj("Default"),Boolean) Then
Select Case data.Name.ToLower()
Case "printerstate"
properties.Add("State", printerState(Convert.ToInt32(data.Value)))
Exit For
Case "printerstatus"
properties.Add("Status", printerStatus(Convert.ToInt32(data.Value)))
Exit For
End Select
End If

Return properties
End Function
Share this answer
Sanju TV 17-Sep-12 5:02am    
Hi friend,

Thanks for your response.

I tried this function the hashtable is getting 2 values 1. paused and Paper Jam but the paper is fully loaded in my printer.

any think i have to do in printer settings or code.
ledtech3 17-Sep-12 8:56am    
It says It is paused and you Have a Paper Jam.
Try pulling all of the paper out of the feeder and reinsert.
Also check for other paper stuck somwhere in the printer.
That should fix it.
Sanju TV 18-Sep-12 2:47am    
i have only one printr and in which no paper is jam
and some time it shows pause and printing i removed all paper and checked again still its showing printing
ledtech3 18-Sep-12 10:25am    
It sounds like your printer driver may be hung.
Most printers have a section in their manual to trouble shoot that problem.
They usually have you unplug the usb cable and then unplug the power in some order.
If you know what the driver name is you can also try to restart the driver using the Services control manager. Lexmark generally start the Friendly name with "Lxd..."
You may also need to restart the "PrintSpooler" service if you just try the restarting method.
Member 13431104 26-Aug-20 8:59am    
can you please share the same code in C# also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900