Jump to content

SplEnumQueueProcessor

From EDM2
Revision as of 18:26, 2 July 2023 by Ak120 (talk | contribs)

This function lists printer queue processors on the local workstation or on a remote server.

Syntax

SplEnumQueueProcessor(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved)

Parameters

pszComputerName (PSZ) - input
Name of computer where queues are to be listed.
A NULL string specifies the local workstation.
ulLevel (ULONG) - input
Level of detail.
The level of detail required. This must be 0.
pBuf (PVOID) - output
Buffer.
The returned contents of the buffer are as follows:
ulLevel Buffer Contents
0 An array of PRQPROCINFO structures
cbBuf (ULONG) - input
Size, in bytes, of Buffer.
It must be greater than 0.
pcReturned (PULONG) - output
Number of entries returned.
pcTotal (PULONG) - output
Total number of entries available.
pcbNeeded (PULONG) - output
Size in bytes of available information.
A value of 0 specifies that the size is not known.
pReserved (PVOID) - output
Reserved value, must be NULL.

Returns

rc (SPLERR) - returns
Return code.
NO_ERROR (0) : No errors occurred.
ERROR_ACCESS_DENIED (5) : Access is denied.
ERROR_NOT_SUPPORTED (50) : This request is not supported by the network.
ERROR_BAD_NETPATH (53) : The network path cannot be located.
ERROR_INVALID_PARAMETER (87) : An invalid parameter is specified.
ERROR_INVALID_LEVEL (124) : The level parameter is invalid.
ERROR_MORE_DATA (234) : Additional data is available.
NERR_NetNotStarted (2102) : The network program is not started.
NERR_BufTooSmall (2123) : The API return buffer is too small.
NERR_InvalidComputer (2351) : The computer name is invalid.

Sample

This sample code enumerates and prints all the queue processors on the local computer.

#define INCL_BASE
#define INCL_SPL
#define INCL_SPLDOSPRINT
#define INCL_SPLERRORS

#include <os2.h>
#include <stdio.h>        /* for printf function   */

INT main ()
{
   SPLERR splerr ;
   ULONG  cbBuf ;
   ULONG  cTotal ;
   ULONG  cReturned ;
   ULONG  cbNeeded ;
   ULONG  i ;
   PSZ    pszComputerName = NULL ;
   PSZ    pszQProcName ;
   PBYTE  pBuf ;

   /* Call the function the first time with zero in cbBuf. The count  */
   /* of bytes needed for the buffer to hold all the info will be     */
   /* returned in cbNeeded.                                           */
   splerr = SplEnumQueueProcessor(pszComputerName, 0L, NULL, 0L,
                                  &cReturned, &cTotal,
                                  &cbNeeded,NULL );

   /* If the return code is ERROR_MORE_DATA or NERR_BufTooSmall,     */
   /* then all the parameters were correct; and we can continue.              */
   if (splerr == ERROR_MORE_DATA || splerr == NERR_BufTooSmall)
   {
      /* Allocate memory for the buffer to hold the returned information. Use */
      /* the count of bytes that were returned by our first call.             */
      if (!DosAllocMem( &pbuf, cbNeeded,
                        PAG_READ|PAG_WRITE|PAG_COMMIT) )
      {
         /* Set count of bytes to the value returned by our first call.       */
         cbBuf = cbNeeded ;

         /* Now call the function a second time with the correct values, and  */
         /* the information will be returned in the buffer.                   */
         splerr = SplEnumQueueProcessor(pszComputerName, 0L, pBuf, cbBuf,
                                        &cReturned, &cTotal,
                                        &cbNeeded,NULL ) ;

         /* If we have no errors, then print out the buffer information.      */
         if (splerr == NO_ERROR)
         {
            /* Set a pointer to point to the beginning of the buffer.         */
            pszQProcName = (PSZ)pBuf;

            /* Print the names that are in the buffer. The count of the number*/
            /* of names in pBuf have been returned in cReturned.              */
            for (i=0;i < cReturned ; i++)
            {
               printf("Queue Processor name - %s\n", pszQProcName) ;

               /* Increment the pointer to point to the next name.            */
               pszQProcName += DRIV_NAME_SIZE + 1;
            }
         }
         /* Free the memory allocated for the buffer.                         */
         DosFreeMem(pBuf) ;
      }
   }
   else
   {
      /* If the first call to the function returned any other error code      */
      /* except ERROR_MORE_DATA or NERR_BufTooSmall, we print the    */
      /* following.                                                           */
      printf("SplEnumQueueProcessor error=%ld\n",splerr ) ;
   }
   DosExit( EXIT_PROCESS , 0 ) ;
   return (splerr);
}

Call Sequence

#define INCL_SPL /* Or use INCL_PM, */
#include <os2.h>

PSZ       pszComputerName;  /*  Name of computer where queues are to be listed. */
ULONG     ulLevel;          /*  Level of detail. */
PVOID     pBuf;             /*  Buffer. */
ULONG     cbBuf;            /*  Size, in bytes, of Buffer. */
PULONG    pcReturned;       /*  Number of entries returned. */
PULONG    pcTotal;          /*  Total number of entries available. */
PULONG    pcbNeeded;        /*  Size in bytes of available information. */
PVOID     pReserved;        /*  Reserved value, must be NULL. */
SPLERR    rc;               /*  Return code. */

rc = SplEnumQueueProcessor(pszComputerName,
       ulLevel, pBuf, cbBuf, pcReturned, pcTotal,
       pcbNeeded, pReserved);

Related Functions