jesper

jesper

  • NA
  • 89
  • 54.4k

I need the exact name of the printdriver, but i get a wrong

Jan 9 2013 2:24 PM
Hi

i have this code:

public void comboFillPrinterDrivers()
        {
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PrinterDriver");

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    listPrinterDriver.Add(queryObj["Name"]);
                }
            }
            catch (ManagementException ef)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + ef.Message);
            }

            comboDriver.DataSource = listPrinterDriver.Distinct().ToList();
        }


This peace of code print out the installed printer drivers i this format:

HP Universal Printing PCL 6,3,Windows x64

i need it, to be: 
HP Universal Printing PCL 6

without ,3,Windows x64

Is ther any way to trim it off, its always like that, with any drivers

:)

Answers (4)