I need to get the default printer name. I\'ll be using C# but I suspect this is more of a framework question and isn\'t language specific.
If you just want the printer name no advantage at all. But WMI is capable of returning a whole bunch of other printer properties:
using System;
using System.Management;
namespace Test
{
class Program
{
static void Main(string[] args)
{
ObjectQuery query = new ObjectQuery(
"Select * From Win32_Printer " +
"Where Default = True");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(query);
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine(mo["Name"] + "\n");
foreach (PropertyData p in mo.Properties)
{
Console.WriteLine(p.Name );
}
}
}
}
}
and not just printers. If you are interested in any kind of computer related data, chances are you can get it with WMI. WQL (the WMI version of SQL) is also one of its advantages.