Platform SDK: Active Directory, ADSI, and Directory Services

IADsPrintJob

The IADsPrintJob interface 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 does the printing, who submitted the document, when it was submitted, and how many pages will be printed.

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.

IADsPrintJob is a dual interface that inherits from IADs. The IADsPrintJob interface exposes the following property methods.

Methods in Vtable Order

IUnknown methods Description
QueryInterface Returns pointers to supported interfaces.
AddRef Increments reference count.
Release Decrements reference count.

IDispatch methods Description
GetTypeInfoCount Gets the number of type descriptions.
GetTypeInfo Gets a description of object's programmable interface.
GetIDsOfNames Maps name of method or property to DISPID.
Invoke Calls one of the object's methods, or gets and sets one of its properties.

IADsPrintJob property methods Description
get_HostPrintQueue Gets the ADsPath string that names the print queue processing this print job.
get_User Name of user submitting 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 of the print job in bytes.
get/put_Description Gets and sets the description of the print job.
get/put_Priority Gets and sets the priority of the print job.
get/put_StartTime Gets and sets the earliest time when the print job should be started.
get/put_UntilTime Gets and sets the time when the print job should be stopped.
get/put_Notify Gets and sets the user to be notified when job is completed.
get/put_NotifyPath The ADsPath string for user to be notified when the job is completed.

Example Code [Visual Basic]

The following Visual Basic code snippet 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
 
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

Example Code [C++]

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

IADsPrintJobOperations *pjo;
IADsPrintQueueOperations *pqo;

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

IADsCollection *pColl;
hr = pqo->PrintJobs(&pColl);

IUnknown *pUnk = NULL;
hr = pColl->get__NewEnum(&pUnk);
pColl->Release();
if (FAILED(hr) ) exit(hr);

IEnumVARIANT *pEnum;
hr = pUnk->QueryInterface(IID_IEnumVARIANT,(void**)&pEnum);
pUnk->Release();
if (FAILED(hr)) exit(hr);

// Now Enumerate
VARIANT var;
ULONG lFetch;
IDispatch *pDisp;

long status;

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();
    }
    VariantClear(&var);
    pDisp=NULL;
    hr = pEnum->Next(1, &var, &lFetch);
};
hr = pEnum->Release();

hr = pqo->Release();

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

IADsPrintJobOperations, IADsPrintQueueOperations::PrintJobs, IADsPrintJob Property Methods