Directory Services

IADsPrintJob

The IADsPrintJob interface is a dual interface that inherits from IADs. It is designed for representing a print job. When a user submits a request to a printer to print a document, a print job is created in the print queue. The property methods allow you to access the information about a print job. Such information includes which printer performs the printing, who submitted the document, when the document was submitted, and how many pages will be printed.

Methods in Vtable Order

The IADsPrintJob interface inherits the methods of the standard COM interfaces:

In addition, IADsPrintJob defines the following methods.

Method Description
get_HostPrintQueue Gets the ADsPath string that names the print queue processing this print job.
get_User Name of user that submitted the print job.
get_UserPath Gets the ADsPath name for user to submit the print job.
get_TimeSubmitted Gets the time when the job was submitted to the print queue.
get_TotalPages Gets the total number of pages in the print job.
get_Size Gets the size, in bytes, of the print job.
get_Description Gets the description of the print job.
put_Description Sets the description of the print job.
get_Priority Gets and sets the priority of the print job.
put_Priority Gets and sets the priority of the print job.
get_StartTime Gets and sets the earliest time when the print job should be started.
put_StartTime Gets and sets the earliest time when the print job should be started.
get_UntilTime Gets and sets the time when the print job should be stopped.
put_UntilTime Gets and sets the time when the print job should be stopped.
get_Notify Gets and sets the user to be notified when job is completed.
put_Notify Gets and sets the user to be notified when job is completed.
get_NotifyPath The ADsPath string for user to be notified when the job is completed.
put_NotifyPath The ADsPath string for user to be notified when the job is completed.

Properties

The IADsPrintJob interface defines the following properties. The preceding table includes access methods for these properties.

Property Description
Description Gets and sets the description of the print job.
HostPrintQueue Gets the ADsPath string that names the print queue processing this print job.
Notify Gets and sets the user to be notified when job is completed.
NotifyPath The ADsPath string for user to be notified when the job is completed.
Priority Gets and sets the priority of the print job.
Size Gets the size, in bytes, of the print job.
StartTime Gets and sets the earliest time when the print job should be started.
TimeSubmitted Gets the time when the job was submitted to the print queue.
TotalPages Gets the total number of pages in the print job.
UntilTime Gets and sets the time when the print job should be stopped.
User Name of user that submitted the print job.
UserPath Gets the ADsPath name for user to submit the print job.

Remarks

To manage a print job across a network, use the IADsPrintJobOperations interface, which supports the functionality to examine the status of a print job and to pause or resume the operation of printing the document, and so on.

To access any print jobs in a print queue, call the IADsPrintQueueOperations::PrintJobs method to obtain the collection object holding all the print jobs in the print queue.

Example Code [Visual Basic]

The following code example shows how to manage a print job submitted to the printer, "\\aMachine\aPrinter".

Dim pq As IADsPrintQueue
Dim pqo As IADsPrintQueueOperations
Dim pj As IADsPrintJob
Dim pjo As IADsPrintJobOperations
Dim pjs As IADsCollection

On Error GoTo Cleanup
 
Set pq = GetObject("WinNT://aMachine/aPrinter")
Set pqo = pq
For Each pj In pqo.PrintJobs
   MsgBox pj.class 
   MsgBox pj.description 
   MsgBox pj.HostPrintQueue
   Set pjo = pj
   If Hex(pjo.status) = 10 ' printing
	pjo.Pause
   Else
	pjo.Resume
  End If
Next

Cleanup:
	If (Err.Number<>0) Then
		MsgBox("An error has occurred. " & Err.Number)
	End If
	Set pq = Nothing
	Set pqo = Nothing
	Set pj = Nothing
	Set pjo = Nothing
	Set pjs = Nothing

Example Code [C++]

The following code example shows how to manage a print job submitted to the printer, "\\aMachine\aPrinter".

IADsPrintJobOperations *pjo = NULL;
IADsPrintQueueOperations *pqo = NULL;
IADsCollection *pColl = NULL;
IUnknown *pUnk = NULL;
IEnumVARIANT *pEnum = NULL;
VARIANT var;
ULONG lFetch = 0;
IDispatch *pDisp = NULL;

long status;

HRESULT hr = S_OK;
hr = ADsGetObject(L"WinNT://aMachine/aPrinter", 
				IID_IADsPrintQueueOperations, 
				(void**)&pqo);
if(FAILED(hr)){goto Cleanup;}

hr = pqo->PrintJobs(&pColl);

hr = pColl->get__NewEnum(&pUnk);
if(FAILED(hr)){goto Cleanup;}

hr = pUnk->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum);
if(FAILED(hr)){goto Cleanup;}

// Now Enumerate
VariantInit(&var);
hr = pEnum->Next(1, &var, &lFetch);
while(hr == S_OK)
{
	if (lFetch == 1)
	{
		pDisp = V_DISPATCH(&var);
		pDisp->QueryInterface(IID_IADsPrintJobOperations, 
							(void**)&pjo);

		pjo->get_Status(&status);
		printf("Job status: %x\n",status);
		if(stats == ADS_JOB_PRINTING) {
			pjo.Pause();
	}
		else {
			pjo.Resume();
	}
		pjo->Release();
}
	pDisp->Release();
	VariantClear(&var);
	hr = pEnum->Next(1, &var, &lFetch);
};

Cleanup:
	VariantClear(&var);
	if(pColl) pColl->Release();
	if(pUnk) pUnk->Release();
	if(pEnum) pEnum->Release();
	if(pqo) pqo->Release();

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IADsPrintJobOperations, IADsPrintQueueOperations::PrintJobs, IADsPrintJob Property Methods