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);
using
System.Diagnostics;
psi.FileName = "rundll32.exe";
psi.Arguments = "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter";
try
{
Process.Start(psi);
}
catch
{
MessageBox.Show("添加打印机失败。请你使用手工方式进行添加。", "添加打印机", MessageBoxButtons.OK, MessageBoxIcon.Information);
添加一下相关引用:
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)