白天有雨

此处应该有掌声

导航

c#中设置默认打印机

using System.Management;
string PrinterName = "HP LaserJet 6L";
ManagementObjectSearcher query;
ManagementObjectCollection queryCollection;
string _classname="SELECT * FROM Win32_Printer";

query=new ManagementObjectSearcher(_classname);
queryCollection = query.Get();

foreach (ManagementObject mo in queryCollection)
{
if (string.Compare(mo["Name"].ToString(),PrinterName,true)==0)
{
mo.InvokeMethod("SetDefaultPrinter",null);
break;
}
}

posted on 2005-12-31 15:25  卓如  阅读(2021)  评论(3编辑  收藏  举报