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
Post a Comment