资源描述:
《c#获取打印机状态+api函数详解》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Runtime.InteropServices;usingSystem.Diagnostics;usingSystem.Drawing.Printing;namespacetestprinter2{pu
2、blicpartialclassForm1:Form{#region预定义类型[FlagsAttribute]publicenumPrinterEnumFlags{PRINTER_ENUM_DEFAULT=0x00000001,PRINTER_ENUM_LOCAL=0x00000002,PRINTER_ENUM_CONNECTIONS=0x00000004,PRINTER_ENUM_FAVORITE=0x00000004,PRINTER_ENUM_NAME=0x00000008,PRINTER_ENUM_REMOTE=0x00000010,PRINTER_
3、ENUM_SHARED=0x00000020,PRINTER_ENUM_NETWORK=0x00000040,PRINTER_ENUM_EXPAND=0x00004000,PRINTER_ENUM_CONTAINER=0x00008000,PRINTER_ENUM_ICONMASK=0x00ff0000,PRINTER_ENUM_ICON1=0x00010000,PRINTER_ENUM_ICON2=0x00020000,PRINTER_ENUM_ICON3=0x00040000,PRINTER_ENUM_ICON4=0x00080000,PRINTER_
4、ENUM_ICON5=0x00100000,PRINTER_ENUM_ICON6=0x00200000,PRINTER_ENUM_ICON7=0x00400000,PRINTER_ENUM_ICON8=0x00800000,PRINTER_ENUM_HIDE=0x01000000}[StructLayout(LayoutKind.Sequential)]publicstructPRINTER_INFO_2{[MarshalAs(UnmanagedType.LPTStr)]publicstringpServerName;[MarshalAs(Unmanage
5、dType.LPTStr)]publicstringpPrinterName;[MarshalAs(UnmanagedType.LPTStr)]publicstringpShareName;[MarshalAs(UnmanagedType.LPTStr)]publicstringpPortName;[MarshalAs(UnmanagedType.LPTStr)]publicstringpDriverName;[MarshalAs(UnmanagedType.LPTStr)]publicstringpComment;[MarshalAs(Unmanaged
6、Type.LPTStr)]publicstringpLocation;publicIntPtrpDevMode;[MarshalAs(UnmanagedType.LPTStr)]publicstringpSepFile;[MarshalAs(UnmanagedType.LPTStr)]publicstringpPrintProcessor;[MarshalAs(UnmanagedType.LPTStr)]publicstringpDatatype;[MarshalAs(UnmanagedType.LPTStr)]publicstringpParameter
7、s;publicIntPtrpSecurityDescriptor;publicuintAttributes;publicuintPriority;publicuintDefaultPriority;publicuintStartTime;publicuintUntilTime;publicuintStatus;publicuintcJobs;publicuintAveragePPM;}#endregion#region引用WindowsAPI//引用API声明[DllImport("winspool.drv",CharSet=CharSet.Auto,S
8、etLastError=true)][return:Marshal