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);
}