问题描述
求助高手!1、获取电脑是否有联机打印机,并将联机打印机设置为默认打印机(状态为“就绪”的打印机)。2、获取打印机状态,如果缺纸、缺墨、卡纸点。3、可以初始化打印机一些参数(打印机首选项)
解决方案
解决方案二:
单纯的网页想获取本地一切硬件信息都是徒劳无功的...只能通过ocx....
解决方案三:
是应用程序,并非WEB程序。
解决方案四:
有人能帮我吗?
解决方案五:
获取打印机状态vb源码:不知你是否下载过,这个对USB打印机没有作用
解决方案六:
不止以上那些,还要看看各个类型的打印机的接口,兼容,特别功能等。打印机,没那么简单。
解决方案七:
收藏的获取打印机相关信息代码,收藏后我还没使用过,你自己试下把usingMicrosoft.Win32;usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.Drawing.Printing;usingSystem.Linq;usingSystem.Management;usingSystem.Text;usingSystem.Threading.Tasks;namespacePrintCellLite.Model.Print{classPrinterPropertyManager{///<summary>///获取打印机的Location///</summary>///<paramname="printerName">打印机名称</param>///<returns>返回一个字符串</returns>publicKeyValuePair<string,int>GetPrinterIPAndPort(stringprinterName){stringport=GetPortValue(printerName);if(string.IsNullOrEmpty(port)){returnnewKeyValuePair<string,int>();}//QueryportName'spropertyfromregeditstring[]portQuerys=GetPortQuerys(port);foreach(varportQueryinportQuerys){RegistryKeyportKey=Registry.LocalMachine.OpenSubKey(portQuery,RegistryKeyPermissionCheck.Default,System.Security.AccessControl.RegistryRights.QueryValues);if(portKey!=null){objectIPValue=portKey.GetValue("IPAddress",String.Empty,RegistryValueOptions.DoNotExpandEnvironmentNames);objectportValue=portKey.GetValue("PortNumber",String.Empty,RegistryValueOptions.DoNotExpandEnvironmentNames);if(IPValue!=null&&portValue!=null){returnnewKeyValuePair<string,int>(IPValue.ToString(),(Int32)portValue);}}}returnnewKeyValuePair<string,int>();}privatestring[]GetPortQuerys(stringportName){returnnewstring[]{@"SystemCurrentControlSetControlPrintMonitorsAdvancedPortMonitorPorts"+portName,@"SystemCurrentControlSetControlPrintMonitorsLocalPortPorts"+portName,@"SystemCurrentControlSetControlPrintMonitorsStandardTCP/IPPortPorts"+portName,@"SystemCurrentControlSetControlPrintMonitorsUSBMonitorPorts"+portName,@"SystemCurrentControlSetControlPrintMonitorsWSDPortPorts"+portName,};}privatestringGetPortValue(stringprinterName){stringport=string.Empty;//Queryprinter'sportNamefromWIN32_Printerstringquery=string.Format("SELECT*fromWin32_PrinterWHEREName='{0}'",printerName);ManagementObjectSearchersearcher=newManagementObjectSearcher(query);ManagementObjectCollectioncoll=searcher.Get();foreach(ManagementObjectprinterincoll){PropertyDataportNameProperty=printer.Properties["PortName"];if(portNameProperty!=null){port=portNameProperty.Value.ToString();}}returnport;}///<summary>///获取打印机名字的列表///</summary>///<returns>返回一个ArrayList</returns>publicArrayListgetPrinterName1(){ArrayListresult=newArrayList();foreach(stringssinPrinterSettings.InstalledPrinters){result.Add(ss);}returnresult;}///<summary>///返回一个整形值,所代表的意思是打印机状态///</summary>///<paramname="printerName">打印机名称</param>///<returns>返回一个int值</returns>publicintPrinterStatusInt(stringprinterName){intret=-1;stringpath=@"win32_printer.DeviceId='"+printerName+"'";ManagementObjectprinter=newManagementObject(path);printer.Get();ret=Convert.ToInt32(printer.Properties["PrinterStatus"].Value);returnret;}///<summary>///获取打印机状态///</summary>///<paramname="printerName">打印机名称</param>///<returns>返回一个字符串</returns>publicstringGetPrinterStatus(stringprinterName){intresult=PrinterStatusInt(printerName);stringstatus="";switch(result){case1:case2:status="Unknow";break;case3:status="Ready";break;case4:case7:status="Printing";break;case5:status="Warning";break;case6:status="Pause";break;case8:status="Offline";break;default:status="Error";break;}returnstatus;}enumPrinterStatus{Other=1,Unknow=2,Ready=3,Printing=4,Warming=5,Pause=6,Printing1=7,Offline=8}}}
解决方案八:
应该是可以的,好像在哪里见过,支持一下