SplEnumQueueProcessor: Difference between revisions
Appearance
mNo edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This function lists printer queue processors on the local workstation or on a remote server. | This function lists printer queue processors on the local workstation or on a remote server. | ||
pszComputerName | == Syntax == | ||
SplEnumQueueProcessor(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved) | |||
A NULL string specifies the local workstation. | == Parameters == | ||
;pszComputerName (PSZ) - input:Name of computer where queues are to be listed. | |||
ulLevel (ULONG) - input | :A NULL string specifies the local workstation. | ||
Level of detail. | ;ulLevel (ULONG) - input:Level of detail. | ||
:The level of detail required. This must be 0. | |||
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 == | == Returns == | ||
;rc (SPLERR) - returns | ;rc (SPLERR) - returns:Return code. | ||
: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 == | == Sample == | ||
This sample code enumerates and prints all the queue processors on the local computer. | This sample code enumerates and prints all the queue processors on the local computer. | ||
<pre> | <pre> | ||
#define INCL_BASE | #define INCL_BASE | ||
#define INCL_SPL | #define INCL_SPL | ||
| Line 145: | Line 113: | ||
return (splerr); | return (splerr); | ||
} | } | ||
</pre> | </pre> | ||
== Call Sequence == | == Call Sequence == | ||
<pre> | <pre> | ||
#define INCL_SPL /* Or use INCL_PM, */ | #define INCL_SPL /* Or use INCL_PM, */ | ||
#include <os2.h> | #include <os2.h> | ||
| Line 169: | Line 133: | ||
ulLevel, pBuf, cbBuf, pcReturned, pcTotal, | ulLevel, pBuf, cbBuf, pcReturned, pcTotal, | ||
pcbNeeded, pReserved); | pcbNeeded, pReserved); | ||
</pre> | </pre> | ||
Latest revision as of 14:08, 4 October 2023
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);