C# 获取系统已经安装的打印机信息Demo
private void Form1_Load(object sender, EventArgs e) { #region 测试 richTextBox1.Clear();//清空信息 //便利所有打印机信息 foreach (string mPrinterName in System.Drawing.Printing.PrinterSettings.InstalledPrinters) { comboBox2.Items.Add(mPrinterName); //实例化PrinterSettings对象 System.Drawing.Printing.PrinterSettings mprinter = new PrinterSettings(); mprinter.PrinterName = mPrinterName;//设置要使用的打印机名称 //判断是否指定了有效的打印机 if (mprinter.IsValid) { //遍历分辨率信息 foreach (PrinterResolution resolution in mprinter.PrinterResolutions) { comboBox1.Items.Add(resolution.ToString());//将分辨率信息添加到下拉列表中 } string prinsize = "";//生命变量存储打印尺寸信息 //遍历所有的打印尺寸信息 foreach (PaperSize size in mprinter.PaperSizes) { if (Enum.IsDefined(size.Kind.GetType(), size.Kind)) { prinsize += size.ToString() + " ";//获取所有的打印尺寸信息 } //显示打印尺寸信息 richTextBox1.AppendText(prinsize + " "); } } } #endregion }