General discussion

  • Creator
    Topic
  • #2082994

    control printer in a vb program

    Locked

    by yhham ·

    Is there a way to monitor or control a printer from a vb program? My program sends many print jobs to a printer at a much faster rate than they get printed. Thus, the print queue eventually becomes huge and the program crashes. Is there a way to monitor when the print queue gets too large so that I can stop sending print jobs and then resend them once the queue gets smaller?

    Any help is greatly appreciated.
    Chris

All Comments

  • Author
    Replies
    • #3900525

      control printer in a vb program

      by shubens ·

      In reply to control printer in a vb program

      Hi,
      In vb, I don’t know but in win32 api I use the function EnumJobs like
      /* 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;
      }
      }
      if Its return error is ERROR_INSUFFICIENT_BUFFER, you could increase buffer size by the same function. I hope this can help you.

    • #3901548

      control printer in a vb program

      by czar andy ·

      In reply to control printer in a vb program

      Yes, the VB API call you are looking for is:
      Public Declare Function EnumJobs Lib “winspool.drv” Alias _
      “EnumJobsA” (ByVal hPrinter As Long, ByVal FirstJob As Long, _
      ByVal NoJobs As Long, ByVal Level As Long, pJob As Byte, ByVal _
      cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long

    • #3739731

      control printer in a vb program

      by yhham ·

      In reply to control printer in a vb program

      This question was auto closed due to inactivity

Viewing 2 reply threads