ASP.NET(C#)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

using System.Management;

  private ManagementObjectSearcher query;
  private 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;
    }
 }

------------------------------------------------------------------
ListViewItem lvi = new ListViewItem(mo["Name"].ToString());
this.listView1.Items.Add(lvi);

posted on 2005-05-24 17:14  battlerstar  阅读(843)  评论(1编辑  收藏  举报