Huy

2 bundles
1 file4 days ago
3

List printer driver by query Win32 API

1234567891011121314151617private void getPrinters()
{
    string queryStr = "SELECT * from Win32_Printer";

    var printerQuery = new ManagementObjectSearcher(queryStr);

    foreach (var printer in printerQuery.Get())
    {
        var name = printer.GetPropertyValue("Name");
        var status = printer.GetPropertyValue("Status");
        var isDefault = printer.GetPropertyValue("Default");
        var isNetworkPrinter = printer.GetPropertyValue("Network");

        Console.WriteLine("{0} (Status: {1}, Default: {2}, Network: {3}",
                    name, status, isDefault, isNetworkPrinter);
    }
}