Description
Sets attributes of the named queue. The caller must have management privileges. The following attributes of the queue can be set:
-
qpri
-
defaultpri
-
runprilimit
-
runlimit
-
sizelimit
-
description
-
pSD (security descriptor)
-
processor_affinity
-
v.batch.shell_list
-
v.batch.defaultshell
-
v.pipe.dest_list
Syntax
DWORD BatchSetQueueInfo(LPCTSTR queue, DWORD level, LPBYTE queueinfo);
Parameters
LPCTSTR queue |
Specifies the name of the queue. |
DWORD level |
Specifies the amount to information to be returned for each queue. Currently, only levels 1 and 2 are supported, which correspond to the BATCH_QUEUE_INFO_1 and BATCH_QUEUE_INFO_2 structures, respectively. |
LPBYTE queueinfo |
Points to a buffer containing the queue info structure. |
Return Values
BATCH_ERROR_NO_SUCH_QUEUE |
The system could not find the named queue. |
ERROR_INVALID_LEVEL |
A level other than 1 or 2 was specified. |
BATCH_ERROR_BAD_QUEUE_NAME |
The syntax of the queue name was not valid. |
BATCH_ERROR_MANAGER_ACCESS_DENIED |
The user does not have manager privileges. |
BATCH_ERROR_BAD_SHELLNAME |
The requested default shell is not in the queue's shell list. |
Example Program
#include <iostream.h>
#include "batchapi.h"
#define MAX_LENGTH 25
void main()
{
LPCTSTR QueName;
long DefPri;
LPBYTE QBuff;
char * pTemp;
char * pTempDesc;
char * pTempShell;
LPTSTR Desc;
LPTSTR * ShellList;
LPTSTR * DestList;
DWORD ReturnVal;
DWORD Level;
DWORD CbSize;
DWORD Need;
DWORD Number;
DWORD QuePri;
DWORD RunPriLim;
DWORD RunLim;
DWORD SizLim;
DWORD ProcAffin;
cout << " STARTING THE EXECUTION OF BATCHSETQUEUEINFO API "<< endl;
cout << endl << " You can set only the following attributes "<<endl
<< " quepriority defaultpriority runprioritylimit runlimit "<<endl
<< " sizelimit description pSD(security descriptor) "<<endl
<< " processor_affinity v.batch.shell_list v.batch.defaultshell "<<endl
<< " v.pipe.dest_list " << endl;
pTemp = new char[MAX_LENGTH];
if (pTemp ==NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
exit(0);
}
pTempShell = new char[MAX_LENGTH];
if (pTempShell == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
exit(0);
}
pTempDesc = new char[MAX_LENGTH];
if (pTempDesc == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
delete [] pTempShell;
exit(0);
}
cout << " Please enter the name of the Queue ";
cin >> pTemp;
QueName = (const char *) pTemp;
cout << " Enter the Level of Enumeration required ";
cin >> Level;
cout << " Enter the Description value ";
cin >> pTempDesc;
Desc = (char *)pTempDesc;
cout << " Enter the QueuPriority value ";
cin >> QuePri;
if (Level == 2)
{
cout << " Enter the DefaultPriority value ";
cin >> DefPri;
cout << " Enter the RunPriorityLimit value ";
cin >> RunPriLim;
cout << " Enter the RunLimit value ";
cin >> RunLim;
cout << " Enter the sizeLimit value ";
cin >> SizLim;
cout << " Enter the ProcessorAffinity value ";
cin >> ProcAffin;
}
ReturnVal = BatchGetQueueInfo( QueName, Level, NULL, 0, &Need);
QBuff = (LPBYTE) LocalAlloc (0,Need);
if (QBuff == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
exit(0);
}
CbSize = Need;
ReturnVal = BatchGetQueueInfo( QueName, Level, QBuff, CbSize, &Need);
if (Level == 2)
{
BATCH_QUEUE_INFO_2 * Jinfo;
Jinfo = (BATCH_QUEUE_INFO_2 *)QBuff;
Jinfo->description = Desc;
Jinfo->defaultpri = DefPri;
Jinfo->qpri = QuePri;
Jinfo->runprilimit = RunPriLim;
Jinfo->runlimit=RunLim;
Jinfo->sizelimit= SizLim;
Jinfo->processor_affinity = ProcAffin;
switch(Jinfo->qtype)
{
case BATCH_QUEUE_TYPE_BATCH:
cout << " Enter the number of valid shells for this Batch queue ";
cin >> Number;
if (Number >0)
{
ShellList = new LPTSTR[Number];
char * TestShell;
TestShell = new char[MAX_LENGTH];
if (QBuff == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
LocalFree(QBuff);
exit(0);
}
for ( DWORD j = 0; j< Number; ++j)
{
cout << " Please enter the ShellName and its absolute path "<<endl
<< " [ as example BATCH=D:\\NTABATCH\\BIN\\BATCH.EXE ]\n "<< endl;
cin >> TestShell;
ShellList[j] = new char[strlen(TestShell)+1];
if (ShellList[j] == NULL){
cout << "unable to allocate the memory.\n Exiting"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
LocalFree(QBuff);
delete [] ShellList;
exit(0);
}
strcpy(ShellList[j],TestShell);
}
cout << " \nEnter the Default ShellName to be used "<<endl
<< " for the above example the ShellName is BATCH \n"<< endl;
cin >> pTempShell;
Jinfo->v.batch.defaultshell = pTempShell;
Jinfo->v.batch.shell_list = ShellList;
}
break;
case BATCH_QUEUE_TYPE_PIPE :
cout << " Enter the number of destinations for this Pipe queue";
cin >> Number;
if (Number >0){
DestList = new LPTSTR[Number];
if (DestList == NULL){
cout << "unable to allocate the memory.\n Exiting program"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
LocalFree(QBuff);
exit(0);
}
char * TestDest;
TestDest = new char[MAX_LENGTH];
if (TestDest == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
LocalFree(QBuff);
delete [] DestList;
exit(0);
}
for ( DWORD j = 0; j< Number; ++j)
{
cout << " Please enter the destination queue ";
cin >> TestDest;
DestList[j] = new char[strlen(TestDest)+1];
if (DestList[j] == NULL){
cout << "unable to allocate the memory.\n Exiting the program"<<endl;
delete [] pTemp;
delete [] pTempShell;
delete [] pTempDesc;
LocalFree(QBuff);
delete [] DestList;
delete [] TestDest;
exit(0);
}
strcpy(DestList[j],TestDest);
}
Jinfo->v.pipe.dest_list = DestList;
}
break;
}
ReturnVal = BatchSetQueueInfo( QueName , Level , (LPBYTE) Jinfo);
}
else
if (Level == 1)
{
BATCH_QUEUE_INFO_1 * Jinfo;
Jinfo = (BATCH_QUEUE_INFO_1 *)QBuff;
Jinfo->description = Desc;
Jinfo->qpri = QuePri;
ReturnVal = BatchSetQueueInfo( QueName , Level , (LPBYTE) Jinfo);
}
switch(ReturnVal)
{
case BATCH_ERROR_NO_SUCH_QUEUE :
cout << " The system could not find the named queue. " << endl;
break;
case ERROR_INVALID_LEVEL :
cout << " A level other than 1 or 2 was specified. " << endl;
break;
case BATCH_ERROR_BAD_QUEUE_NAME :
cout << " The syntax of the queue name was not valid. " << endl;
break;
case BATCH_ERROR_MANAGER_ACCESS_DENIED :
cout << " The user does not have manager privileges. " << endl;
break;
default:
cout << "SUCCESSFUL COMPLETION OF BATCHQUEUSETINFO INFORMATION"<< endl;
}
cout << " COMPLETED THE EXECUTION OF BATCHSETQUEUEINFO API "<< endl;
delete [] pTemp;
delete [] pTempDesc;
LocalFree(QBuff);
}