Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to varify the printing status in C++ in LAN printer.

Posted on 2000-04-06
1
Medium Priority
?
275 Views
Last Modified: 2008-02-20
IF I sent some document to print in the shared LAN printer printing pools, How to get the result in C++ that a document has been printed and cleared in the printing pools? (OS: Windows NT)

f.e. I sent 1.doc, 2.doc, 3.doc in order, and after 1.doc finished, How to get an infomation to deal with in the C++ application?

0
Comment
Question by:zhiyong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 600 total points
ID: 2692287
To get printer status:http://support.microsoft.com/support/kb/articles/q160/1/29.asp
Example of using:
   BOOL IsPrinterError(HANDLE hPrinter)   {       JOB_INFO_2  *pJobs;
       int         cJobs,                   i;
       DWORD       dwPrinterStatus;       /*
        *  Get the state information for the Printer Queue and
        *  the jobs in the Printer Queue.        */
       if (!GetJobs(hPrinter, &pJobs, &cJobs, &dwPrinterStatus))
           return FALSE;       /*
        *  If the Printer reports an error, believe it.        */
       if (dwPrinterStatus &           (PRINTER_STATUS_ERROR |
           PRINTER_STATUS_PAPER_JAM |           PRINTER_STATUS_PAPER_OUT |
           PRINTER_STATUS_PAPER_PROBLEM |
           PRINTER_STATUS_OUTPUT_BIN_FULL |
           PRINTER_STATUS_NOT_AVAILABLE |           PRINTER_STATUS_NO_TONER |
           PRINTER_STATUS_OUT_OF_MEMORY |           PRINTER_STATUS_OFFLINE |
         PRINTER_STATUS_DOOR_OPEN))       {           return TRUE;       }
   BOOL GetJobs(HANDLE hPrinter,        /* Handle to the printer. */
                JOB_INFO_2 **ppJobInfo, /* Pointer to be filled.  */
                int *pcJobs,            /* Count of jobs filled.  */
                DWORD *pStatus)         /* Print Queue status.    */    {
       DWORD               cByteNeeded,                           nReturned,
                           cByteUsed;
       JOB_INFO_2          *pJobStorage = NULL;
       PRINTER_INFO_2       *pPrinterInfo = NULL;
   /* Get the buffer size needed. */
       if (!GetPrinter(hPrinter, 2, NULL, 0, &cByteNeeded))       {
           if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
               return FALSE;       }
       pPrinterInfo = (PRINTER_INFO_2 *)malloc(cByteNeeded);
       if (!(pPrinterInfo))           /* Failure to allocate memory. */
           return FALSE;       /* Get the printer information. */
       if (!GetPrinter(hPrinter,               2,
               (LPSTR)pPrinterInfo,               cByteNeeded,
               &cByteUsed))       {
           /* Failure to access the printer. */            free(pPrinterInfo);
           pPrinterInfo = NULL;           return FALSE;       }
       /* Get job storage space. */
       if (!EnumJobs(hPrinter,
               0,pPrinterInfo->cJobs,               2,
               NULL,               0,               (LPDWORD)&cByteNeeded,
               (LPDWORD)&nReturned))       {
           if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)           {
               free(pPrinterInfo);               pPrinterInfo = NULL;
               return FALSE;           }       }
       pJobStorage = (JOB_INFO_2 *)malloc(cByteNeeded);       if (!pJobStorage)
       {           /* Failure to allocate Job storage space. */
           free(pPrinterInfo);           pPrinterInfo = NULL;
         return FALSE;       }       ZeroMemory(pJobStorage, cByteNeeded);
       /* Get the list of jobs. */        if (!EnumJobs(hPrinter,
             0,               pPrinterInfo->cJobs,               2,
             (LPBYTE)pJobStorage,               cByteNeeded,
             (LPDWORD)&cByteUsed,               (LPDWORD)&nReturned))       {
         free(pPrinterInfo);           free(pJobStorage);
         pJobStorage = NULL;           pPrinterInfo = NULL;
         return FALSE;       }       /*        *  Return the information.
      */        *pcJobs = nReturned;       *pStatus = pPrinterInfo->Status;
       *ppJobInfo = pJobStorage;       free(pPrinterInfo);       return TRUE;
   }

I hope, it helps. Alex
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question