Description
Returns information about all of the queues on a server.
Syntax
DWORD BatchEnumerateQueues(LPCTSTR server, DWORD level, LPBYTE qbuff, DWORD cbsize, LPDWORD cbneeded, LPDWORD qcount);
Parameters
LPCTSTR server |
Specifies the name of a server. If this parameter is null or empty, then queues from the local server are enumerated. |
DWORD level |
Specifies the amount to information to be returned for each job. Currently, only levels 1 and 2 are supported, which correspond to the BATCH_QUEUE_INFO_1 and BATCH_QUEUE_INFO_2 structures, respectively. |
LPBYTE qbuff |
Buffer space to store an array of BATCH_QUEUE_INFO structures. |
DWORD cbsize |
Specifies the size of the buffer in bytes. |
LPDWORD cbneeded |
Specifies the size of the returned information. If cbsize is too small, ERROR_INSUFFICIENT_BUFFER is returned, and cbneeded is set to the needed size. |
LPDWORD qcount |
Provides a pointer to contain the number of queues returned in the qbuf. |
Return Values
BATCH_ERROR_BAD_SERVER_NAME |
The syntax of the server name was invalid. |
ERROR_INVALID_LEVEL |
The level parameter is not 1 or 2. |
Example Program
#include <iostream.h>
#include "batchapi.h"
#define MAX_LENGTH 25
void main()
{
char * pTemp;
LPBYTE QBuff;
LPCTSTR ServName;
DWORD Level;
DWORD CbSize;
DWORD ReturnVal;
DWORD Need;
DWORD Qcount;
cout << "STARTING THE EXECUTION OF BATCHENUMERATEQUEUE API "<< endl;
pTemp = new char [MAX_LENGTH];
if (pTemp == NULL){
cout << "Unable to allocate the memory.\n Exiting"<<endl;
exit(0);
}
cout << " Enter the Server to Enumerate the Queues ";
cin >> pTemp;
ServName = (const char *) pTemp;
cout << " Enter the Level with Which to Enumerate the Jobs ";
cin >> Level;
ReturnVal = BatchEnumerateQueues(ServName,Level,NULL,0,&Need,&Qcount);
QBuff = (LPBYTE)LocalAlloc(0,Need);
if (QBuff == NULL){
cout << "Unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
exit(0);
}
CbSize = Need;
ReturnVal = BatchEnumerateQueues(ServName,Level,QBuff,CbSize,&Need,&Qcount);
// Now we have the Data(in QBuff) about the Queues from the server ServName which can
// be retrieved using an BATCH_JOB_INFO_2 or a BATCH_JOB_INFO_1 pointer variable
// which can be seen by seeing the BatchSetQueueInfo api example.
switch(ReturnVal)
{
case BATCH_ERROR_BAD_SERVER_NAME :
cout << " The syntax of the server name was invalid. " << endl;
break;
case ERROR_INVALID_LEVEL :
cout << " The level parameter is not 1 or 2. " << endl;
break;
default:
cout << "SUCCESSFUL COMPLETION OF ENUMERATION"<<endl;
}
cout << "COMPLETED THE EXECUTION OF BATCHENUMERATEQUEUE API "<< endl;
delete [] pTemp;
LocalFree(QBuff);
}