Справочник по C#

    Исходники по языку программирования CSharp

    Список установленных притеров: Справочник по C#

    /
    /
    /
    18 Views


    public List GetInstalledPrinters()
    {
    List printerList = new List();
    
    try
    {
    //set the scope of this search to the local machine
    ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath);
    //connect to the machine
    scope.Connect();
    
    //build the SelectQuery to pull from Win32_Printer
    SelectQuery query = new SelectQuery("select * from Win32_Printer");
    
    ManagementClass m = new ManagementClass("Win32_Printer");
    
    ManagementObjectSearcher obj = new ManagementObjectSearcher(scope, query);
    
    //now loop through what is found and populate our Generic list with
    //the names of all installed printers on the local machine
    using (ManagementObjectCollection printers = m.GetInstances())
    foreach (ManagementObject printer in printers)
    printerList.Add(printer["Name"].ToString());
    
    printerList.Sort();
    
    return printerList;
    }
    catch (Exception ex)
    {
    return null;
    }
    }

    Список установленных притеров: Справочник по C#

    0.00 (0%) 0 votes

    moyadcode13
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest
    moyadcode10
    moyadcode11
    moyadcode9