c#(winform)获取本地打印机

引用 using System.Drawing.Printing;

        PrintDocument prtdoc = new PrintDocument();
       
        private void Form3_Load(object sender, EventArgs e)
        {
            string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名

            foreach (string ss in PrinterSettings.InstalledPrinters)
            {
                ///在列表框中列出所有的打印机,
                this.listBox1.Items.Add(ss);
                if (ss == strDefaultPrinter)//把默认打印机设为缺省值
                {
                    listBox1.SelectedIndex = listBox1.Items.IndexOf(ss);
                }
            }
        }

 

posted @ 2020-11-20 10:42  许宝  阅读(878)  评论(0编辑  收藏  举报