Does PrintQueue or PrintTicket has any property or method to determine the selected printer is a virtual printer?

286 views Asked by At

Does PrintQueue or PrintTicket has any property or method to determine the selected printer is a virtual printer? For example, the process should restrict M/S Xps Document Writer, Fax, Send To OneNote, PDF Printer etc. Only actual printers should be filtered out from LocalPrintServer and provide a list dynamically.

    using (var _LocalPrintServer = new LocalPrintServer())
    {
        foreach (PrintQueue _pq in _LocalPrintServer.GetPrintQueues())
        {
            // To Find some way to determine this _pq is NOT a virtual printer
        }
    }
1

There are 1 answers

1
TheGeneral On

You will need to probe the properties in Win32_Printer class

System.Management.ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_Printer");
ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);
ManagementObjectCollection moc = mos.Get();
foreach( ManagementObject mo in moc )
{

    string name = mo["Name"].ToString();
    string language = mo["DefaultLanguage"].ToString();
    MessageBox.Show(String.Format("Printer: {0} -- Language: {1}", name, language);
}

Maybe you could check the languages field for postscipt or pcl (only a guess), though you might just have to check the difference between all your printers to find an loosely indicative way.

In any case i can be fairly confident there is no way to exactly check for what you want as there is no field called virtual printer as to your specs.