C#获取列印机(打印机)方法二
C# 列印机(打印机)方法一
创新互联是一家企业级云计算解决方案提供商,超15年IDC数据中心运营经验。主营GPU显卡服务器,站群服务器,成都服务器托管,海外高防服务器,服务器机柜,动态拨号VPS,海外云手机,海外云服务器,海外服务器租用托管等。
C# 列印机(打印机)方法二:
使用类:ManagementObjectCollection、ManagementObjectSearcher、ManagementObject、
Dictionary
private static ManagementObjectCollection queryCollection; private static string _classname = "SELECT * FROM Win32_Printer"; private static DictionaryGetPrinter() { Dictionary dict = new Dictionary (); ManagementObjectSearcher query = new ManagementObjectSearcher(_classname); queryCollection = query.Get(); int count = 0; foreach (ManagementObject mo in queryCollection) { string oldName = mo["Name"].ToString(); Console.WriteLine(oldName); if (IsChineseLetter(oldName, "來自")) { count++; string newName = "Printer_" + count.ToString(); Console.WriteLine("\n\r\n\r非法打印機名稱:" + oldName + "\n\r將改名為:" + newName); dict.Add(newName, mo); } } return dict; }
当前名称:C#获取列印机(打印机)方法二
分享路径:http://scyanting.com/article/jgjjsi.html