诗人、学者、民主战士

吴海晶

博客园 首页 联系 订阅 管理

C#调用Windows添加打印机向导

 

检查是否系统已经安装打印机:

using   System.Drawing.Printing 
if(PrinterSettings.InstalledPrinters.Count <=0) 

        MessageBox.Show( "没找到打印机 ") 

 

添加一下相关引用:

using System.Diagnostics;

 

 

ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = "rundll32.exe";
            psi.Arguments = "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter";
            try
            {
                Process.Start(psi);
            }
            catch
            {
                MessageBox.Show("添加打印机失败。请你使用手工方式进行添加。", "添加打印机", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

posted on 2012-04-11 19:37  吴海晶  阅读(469)  评论(0编辑  收藏  举报