Click here to Skip to main content
14,739,585 members
Home » Discussions » ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
Richard MacCutchan9-Mar-12 21:52
mveRichard MacCutchan9-Mar-12 21:52 
GeneralRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
MrKBA21-Mar-12 3:11
MemberMrKBA21-Mar-12 3:11 
GeneralRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
barneyman21-Mar-12 3:34
Memberbarneyman21-Mar-12 3:34 
GeneralRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
MrKBA21-Mar-12 3:46
MemberMrKBA21-Mar-12 3:46 
GeneralRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
barneyman21-Mar-12 13:25
Memberbarneyman21-Mar-12 13:25 
AnswerRe: Release COM dll crash problem (Windows 7 64bit OS) Pin
MrKBA21-Mar-12 3:10
MemberMrKBA21-Mar-12 3:10 
QuestionHow do I detect when a print job starts? Pin
LetsMond2-Mar-12 2:11
MemberLetsMond2-Mar-12 2:11 
AnswerRe: How do I detect when a print job starts? Pin
AminMhmdi7-Mar-12 21:27
professionalAminMhmdi7-Mar-12 21:27 
use JOB_INFO struct
The JOB_INFO structures contain a Status member and a pStatus member. Both members contain status information of a print job reported by the port monitor. These two members differ in that the Status member is a bit field of states that contains predetermined values, while the pStatus member is a pointer to a string that could contain just about anything.
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;

  }

  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))
      {
          free( pJobs );
          return TRUE;
      }

      /*
       *  Find the Job in the Queue that is printing.
       */
      for (i=0; i < cJobs; i++)
      {
          if (pJobs[i].Status & JOB_STATUS_PRINTING)
          {
              /*
               *  If the job is in an error state,
               *  report an error for the printer.
               *  Code could be inserted here to
               *  attempt an interpretation of the
               *  pStatus member as well.
               */
              if (pJobs[i].Status &
                  (JOB_STATUS_ERROR |
                  JOB_STATUS_OFFLINE |
                  JOB_STATUS_PAPEROUT |
                  JOB_STATUS_BLOCKED_DEVQ))
              {
                  free( pJobs );
                  return TRUE;
              }
          }
      }

      /*
       *  No error condition.
       */
      free( pJobs );
      return FALSE;

  }

GeneralRe: How do I detect when a print job starts? Pin
LetsMond7-Mar-12 23:30
MemberLetsMond7-Mar-12 23:30 
QuestionATL Sink in .NET process Pin
Vikram123428-Feb-12 16:50
MemberVikram123428-Feb-12 16:50 
AnswerRe: ATL Sink in .NET process Pin
barneyman29-Feb-12 17:01
Memberbarneyman29-Feb-12 17:01 
GeneralRe: ATL Sink in .NET process Pin
Vikram123429-Feb-12 17:10
MemberVikram123429-Feb-12 17:10 
GeneralRe: ATL Sink in .NET process Pin
barneyman29-Feb-12 17:17
Memberbarneyman29-Feb-12 17:17 
GeneralRe: ATL Sink in .NET process Pin
Vikram123429-Feb-12 17:22
MemberVikram123429-Feb-12 17:22 
GeneralRe: ATL Sink in .NET process Pin
Vikram12341-Mar-12 8:56
MemberVikram12341-Mar-12 8:56 
GeneralRe: ATL Sink in .NET process Pin
barneyman1-Mar-12 18:36
Memberbarneyman1-Mar-12 18:36 
AnswerRe: ATL Sink in .NET process Pin
ThatsAlok22-Jun-12 0:10
MemberThatsAlok22-Jun-12 0:10 
QuestionGet Notification of Wrong Password Attempt Pin
Member 857955627-Feb-12 4:42
MemberMember 857955627-Feb-12 4:42 
AnswerRe: Get Notification of Wrong Password Attempt Pin
Richard MacCutchan27-Feb-12 5:19
mveRichard MacCutchan27-Feb-12 5:19 
AnswerRe: Get Notification of Wrong Password Attempt Pin
peterchen24-Mar-12 7:32
Memberpeterchen24-Mar-12 7:32 
QuestionEntry point name correction in compiled DLL, Swig/GCC/CC/LD and exports Pin
XenobiusII24-Feb-12 20:09
MemberXenobiusII24-Feb-12 20:09 
AnswerRe: Entry point name correction in compiled DLL, Swig/GCC/CC/LD and exports Pin
Richard MacCutchan25-Feb-12 0:43
mveRichard MacCutchan25-Feb-12 0:43 
Questionprojects with C++ Pin
niara 24-Feb-12 14:09
Memberniara 24-Feb-12 14:09 
AnswerRe: projects with C++ Pin
Richard MacCutchan25-Feb-12 0:37
mveRichard MacCutchan25-Feb-12 0:37 
QuestionOnChar not called Pin
Member 199473021-Feb-12 3:20
MemberMember 199473021-Feb-12 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.