using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using System.Diagnostics;using System.Drawing.Printing;namespace testprinter2{publicpartialclassForm1 : 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_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_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)]publicstring pServerName; [MarshalAs(UnmanagedType.LPTStr)]publicstring pPrinterName; [MarshalAs(UnmanagedType.LPTStr)]publicstring pShareName; [MarshalAs(UnmanagedType.LPTStr)]publicstring pPortName; [MarshalAs(UnmanagedType.LPTStr)]publicstring pDriverName; [MarshalAs(UnmanagedType.LPTStr)]publicstring pComment; [MarshalAs(UnmanagedType.LPTStr)]publicstring pLocation;publicIntPtr pDevMode; [MarshalAs(UnmanagedType.LPTStr)]publicstring pSepFile; [MarshalAs(UnmanagedType.LPTStr)]publicstring pPrintProcessor; [MarshalAs(UnmanagedType.LPTStr)]publicstring pDatatype; [MarshalAs(UnmanagedType.LPTStr)]publicstring pParameters;publicIntPtr pSecurityDescriptor;publicuint Attributes;publicuint Priority;publicuint Defaul...