c# - Check printer if connected to pc or not -



c# - Check printer if connected to pc or not -

i need write code prompt message "printer connected" when printer plugged computer , prompt message "printer not connected" when plug out printer computer. want list printers available through combobox. how can in c# using visual studio?

you should utilize winspool.lib

c# signature :

[dllimport("winspool.drv", entrypoint = "openprintera", setlasterror = true, charset = charset.ansi, exactspelling = true, callingconvention = callingconvention.stdcall)] public static extern bool openprinter([marshalas(unmanagedtype.lpstr)] string szprinter, out intptr hprinter, intptr pd);

edit:

you can utilize this

foreach (string printer in system.drawing.printing.printersettings.installedprinters) { //add in combo box }

c#

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -