Directory Services

IADsPrintJobOperations

The IADsPrintJobOperations interface is a dual interface that inherits from IADs. It is used to control a print job across a network. A print job object that implements the IADsPrintJob interface will also support the following features for this interface:

Methods in Vtable Order

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

In addition, IADsPrintJobOperations defines the following methods.

Method Description
get_Status Tracks the status of the print job.
get_TimeElapsed Tracks the elapsed time, in seconds, since the job started printing.
get_PagesPrinted Tracks the number of pages completed.
get_Position Tracks the numeric position of the print job in the print queue.
put_Position Tracks the numeric position of the print job in the print queue.
Pause Pauses processing of this print job.
Resume Resumes processing of this print job.

Properties

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

Property Description
PagesPrinted Tracks the number of pages completed.
Position Tracks the numeric position of the print job in the print queue.
Status Tracks the status of the print job.
TimeElapsed Tracks the elapsed time, in seconds, since the job started printing.

Example Code [Visual Basic]

The following code example shows how this interface can be used.

Dim pqo As IADsPrintQueueOperations
Dim pjo As IADsPrintJobOperations
On Error GoTo Cleanup

Set pqo = GetObject("WinNT://aMachine/aPrinter")
For Each pj In pqo.PrintJobs
	Set pjo = pj
	MsgBox "Print job status: " & Hex(pjo.status)
Next

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

Example Code [C++]

The following code example shows how this interface can be used.

IADsPrintJobOperations *pjo = NULL;
IADsPrintQueueOperations *pqo = NULL;
IADsCollection *pColl = NULL;
IUnknown *pUnk = NULL;
IEnumVARIANT *pEnum = NULL;
HRESULT hr = S_OK;

hr = ADsGetObject(L"WinNT://aMachine/aPrinter", 
		IID_IADsPrintQueueOperations, 
		(void**)&pqo);

if(FAILED(hr)) {goto Cleanup;}

hr = pqo->PrintJobs(&pColl);
if(FAILED(hr)) {goto Cleanup;}

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

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

// Enumerate.
VARIANT var;
ULONG lFetch = 0;
IDispatch *pDisp = NULL;

long status = 0;
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);

	 pjo->Release();
}
	pDisp->Release();
	VariantClear(&var);
	hr = pEnum->Next(1, &var, &lFetch);
};

Cleanup:
	VariantClear(&var);
	if(pEnum) pEnum->Release();
	if(pUnk) pUnk->Release();
	if(pqo) pqo->Release();
	if(pColl) pColl->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

IADsPrintJob