Platform SDK: Active Directory, ADSI, and Directory Services

IADsPrintQueue

The IADsPrintQueue interface represents a printer on a network. The property methods of this interface allow you to access the about a printer. Such information includes the printer model, its physical location, the network address, and so on. You can use this interface to browse through a collection of print jobs in the print queue. To control a printer across a network, you use the IADsPrintQueueOperations interface. To obtain a collection of the print jobs, call the IADsPrintQueueOperations::PrintJobs method.

In Windows NT®/Windows® 2000, a printer, or a print queue, is managed by a host computer. If the path to a print queue is known, you can bind to it as you would to any other ADSI objects. For example,

Dim pq as IADsPrintQueue
Set pq = GetObject("WinNT://aMachine/aPrinter")

or in C++,

IADsPrintQueue *pq;
LPWSTR adsPath = L"WinNT://aMachine/aPrinter";
HRESULT hr = ADsGetObject(adsPath,
                          IID_IADsPrintQueue,
                          (void**)&pq); 

To enumerate all print queues on a given computer, proceed as follows:

  1. Bind to the computer object.
  2. Determine if the computer contains any "PrintQueue" objects.
  3. Walk through all the found printer objects.

The following code snippet enumerates all the printers on a given computer.

    Dim cont As IADsContainer
    Dim pq As IADsPrintQueue
 
    ' Bind to the computer object
    Set cont = GetObject("WinNT://romulus,computer")

    cont.Filter = Array("PrintQueue")
    For Each p In cont
       Set pq = GetObject(p.ADsPath)
       MsgBox pq.Name & " is a " & pq.Model
    Next p

IADsPrintQueue is a dual interface that inherits from IADs. The IADsPrintQueue 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.

IADsPrintQueue property methods Description
get/put_PrinterPath Gets and sets the path where a shared printer can be accessed.
get/put_Model Gets and sets the name of the driver used by this print queue.
get/put_Datatype Gets and sets the data type that can be processed by this print queue.
get/put_PrintProcessor Gets and sets the print processor associated with this print queue.
get/put_Description Gets and sets the description of this print queue.
get/put_Location Gets and sets the administrator's description of the print queue location.
get/put_StartTime Gets and sets the time when the print queue starts processing jobs.
get/put_UntilTime Gets and sets the time at which the print queue stops processing jobs.
get/put_DefaultJobPriority Gets and sets the default priority assigned to each print job.
get/put_Priority Gets and sets the priority of this printer object's job queue for connected devices.
get/put_BannerPage Gets and sets the file system path to the banner page file used to separate jobs.
get/put_PrintDevices Gets and sets the names of print devices that this print queue uses as spooling devices.
get/put_NetAddresses Gets and sets the binding information.

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

IADsPrintQueueOperations, IADsPrintQueueOperations::PrintJobs, IADsPrintQueue Property Methods