static void Main(string[] args) { ConnectionOptions objConnection = new ConnectionOptions(); string strMachineName = System.Environment.MachineName; ManagementScope objScope = new ManagementScope(@"\\" + strMachineName + @"\root\cimv2");//, objConnection); objScope.Connect(); SelectQuery selectQuery = new SelectQuery(); selectQuery.QueryString = "Select * from win32_Printer"; ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery); ManagementObjectCollection MOC = MOS.Get(); foreach (ManagementObject mo in MOC) { Console.WriteLine(MOC.Count.ToString()); Console.WriteLine(mo["Name"].ToString().ToUpper()); if ((bool)mo["Default"]) { Console.WriteLine("This is Default printer"); } } Console.ReadLine(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)