C# 列印机(打印机)方法一
C# 列印机(打印机)方法二:
使用类:ManagementObjectCollection、ManagementObjectSearcher、ManagementObject、
Dictionary
private static ManagementObjectCollection queryCollection; private static string _classname = "SELECT * FROM Win32_Printer"; private static Dictionary<string, ManagementObject> GetPrinter() { Dictionary<string, ManagementObject> dict = new Dictionary<string, ManagementObject>(); 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; }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。