• (C#) ---> How to Get Real Number of Copies from a doc sent to printer?

    From vitorcrdias@gmail.com@21:1/5 to All on Sat May 5 16:34:29 2018
    My task is very simple, but I cannot do that with WMI. So I thought I could get some info using WMI and than adding some pinvoke to get the copies. I don't have a real printer to test printed pages, so my point is the number of jobs in print queue, name
    of printer, name of submitter (Owner), name of document, total pages and copies by doc.
    Here is some code that I was trying:
    ------------------------------------
    //Devolve uma lista com todas as impressoras instaladas localmente na máquina
    foreach (string printer in PrinterSettings.InstalledPrinters)
    {

    if (!printer.Equals(null))
    {
    //preenchendo listBoxImpressoras com nomes de impressoras
    listBoxImpressoras.Items.Add(printer);
    }
    else
    {
    listBoxImpressoras.Items.Add("Não há impressoras instaladas nesta máquina!");
    MessageBox.Show("Instale o driver da impressora em questão ou verifique se há \n problema com o driver.");
    }

    }
    ----------------------------
    Of course this piece of code don't have WMI, but I will use something like this one:
    ----------------------------
    ManagementObjectSearcher searcher =
    new ManagementObjectSearcher("root\\CIMV2",
    "SELECT * FROM Win32_PrintJob WHERE Name ='"+docName+"'");

    foreach (ManagementObject queryObj in searcher.Get())
    {
    Console.WriteLine("-----------------------------------");
    Console.WriteLine("Win32_PrintJob instance");
    Console.WriteLine("-----------------------------------");
    Console.WriteLine("Document: {0}", queryObj["Document"]);
    }
    ------------------------------
    So I have 3 listBox to populate. One goes printer's name, another goes doc's name and last one goes details about each job.
    ------------------------------
    Can someone help? Thank you so much and God may bless you a lot.
    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)