现在的位置: 首页 > 综合 > 正文

C#获取本机连接的打印机属性

2013年12月06日 ⁄ 综合 ⁄ 共 3026字 ⁄ 字号 评论关闭

注意:这里取到的信息是本机连接上,并且装过驱动的打印机信息,也就是在 开始-----打印机和传真 中列出的所有打印机属性。而不是随便将一个打印机的数据线连接到电脑上的情况。另外,如果本机连接的一个能够使用的打印机,某一天去掉数据线后,他仍然在 开始-----打印机和传真 中有图标时,仍然可以获取到信息,而且打印机状态是“空闲”。

 

界面很简单,一个comboBox,一个textBox

 

 

 

 

首先在引用中需要引入System.Management,还要using System.Management;

 

 

获取当前电脑识别的打印机名

  

获取打印机的所有属性:

 

属性如下:

 

Attributes : 2584
Availability :
AvailableJobSheets :
AveragePagesPerMinute : 0
Capabilities : System.UInt16[]
CapabilityDescriptions : System.String[]
Caption : //print/Canon MF3200 Series
CharSetsSupported :
Comment :
ConfigManagerErrorCode :
ConfigManagerUserConfig :
CreationClassName : Win32_Printer
CurrentCapabilities :
CurrentCharSet :
CurrentLanguage :
CurrentMimeType :
CurrentNaturalLanguage :
CurrentPaperType :
Default : False
DefaultCapabilities :
DefaultCopies :
DefaultLanguage :
DefaultMimeType :
DefaultNumberUp :
DefaultPaperType :
DefaultPriority : 0
Description :
DetectedErrorState : 0
DeviceID : //print/Canon MF3200 Series
Direct : False
DoCompleteFirst : True
DriverName : Canon MF3200 Series
EnableBIDI : True
EnableDevQueryPrint : False
ErrorCleared :
ErrorDescription :
ErrorInformation :
ExtendedDetectedErrorState : 0
ExtendedPrinterStatus : 2
Hidden : False
HorizontalResolution : 600
InstallDate :
JobCountSinceLastReset : 0  //当前任务数
KeepPrintedJobs : False
LanguagesSupported :
LastErrorCode :
Local : False
Location :
MarkingTechnology :
MaxCopies :
MaxNumberUp :
MaxSizeSupported :
MimeTypesSupported :
Name : //print/Canon MF3200 Series
NaturalLanguagesSupported :
Network : True
PaperSizesSupported : System.UInt16[]
PaperTypesAvailable :
Parameters :
PNPDeviceID :
PortName : USB001
PowerManagementCapabilities :
PowerManagementSupported :
PrinterPaperNames : System.String[]
PrinterState : 0  //打印机状态
PrinterStatus : 3
PrintJobDataType : RAW
PrintProcessor : WinPrint
Priority : 1
Published : False
Queued : False
RawOnly : False
SeparatorFile :
ServerName : //print
Shared : True
ShareName : CanonMF3
SpoolEnabled : True
StartTime :
Status : Unknown
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : //print
TimeOfLastReset :
UntilTime :
VerticalResolution : 600
WorkOffline : False  //是否离线

 

其中PrinterState的对应关系如下:

 

 

抱歉!评论已关闭.