IADsPrintQueue interface (iads.h)

The IADsPrintQueue interface represents a printer on a network. It is a dual interface that inherits from IADs. The property methods of this interface enables you to access data about a printer, for example printer model, physical location, and network address.

Inheritance

The IADsPrintQueue interface inherits from IDispatch and IADs. IADsPrintQueue also has these types of members:

Remarks

Use this interface to browse a collection of print jobs in the print queue. To control a printer across a network, use the IADsPrintQueueOperations interface. To obtain a collection of the print jobs, call the IADsPrintQueueOperations::PrintJobs method.

In Windows, a printer, or a print queue, is managed by a host computer. If the path to a print queue is known, bind to it as to any other ADSI objects.

The following Visual Basic code example shows the bind operation.

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

The following C++ code example shows the bind operation.

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

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

Examples

The following code example enumerates printers on a given computer.

Dim cont As IADsContainer
Dim pq As IADsPrintQueue

On Error GoTo Cleanup
 
' Bind to the computer object
Set cont = GetObject("WinNT://fabrikam1,computer")

cont.Filter = Array("PrintQueue")

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

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

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header iads.h

See also

IADs

IADsPrintQueue Property Methods

IADsPrintQueueOperations

IADsPrintQueueOperations::PrintJobs

IDispatch