zemp,
Here is a quick modification of some code I use to get the printer bins.
You will need a form with a combobox on it and the following code (form1, combo1)...
[tt]
Option Explicit
Private Sub Form_Load()
Dim P As Printer
For Each P In Printers
Combo1.AddItem P.DeviceName
Next P
End Sub
Private Sub Combo1_Click()
Call GetPaperNames(Combo1.Text)
End Sub
[/tt]
then in a module...
[tt]
Option Explicit
Private Const DEFAULT_VALUES = 0
Private Const DC_PAPERNAMES = 16
Private Const DC_PAPERS = 2
Private Const DC_PAPERSIZE = 3
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As DEVMODE
DesiredAccess As Long
End Type
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Function GetPaperNames(strPrinterName As String) As String
' Uses the DeviceCapabilities API function to display a
' message with the name of the default printer and a
' list of the paper it supports.
Dim lngPaperCount As Long
Dim lngCounter As Long
Dim strDeviceName As String
Dim strDevicePort As String
Dim strPaperNameList As String
Dim strPaperName As String
Dim intLength As Integer
Dim strMsg As String
Dim intPaperNumber() As Integer
Dim P As Printer
Dim Pnt() As POINTAPI
Dim strTemp As String, intTemp As Integer
For Each P In Printers
If P.DeviceName = strPrinterName Then Exit For
Next P
On Error GoTo GetPaperNames_Err
' Get name and port of the default printer.
strDeviceName = P.DeviceName
strDevicePort = P.Port
' Get count of paper bin names supported by printer.
lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, lpPort:=strDevicePort, iIndex:=DC_PAPERNAMES, lpOutput:=ByVal vbNullString, lpDevMode:=DEFAULT_VALUES)
' Re-dimension arrays to count of paper names.
ReDim intPaperNumber(1 To lngPaperCount)
ReDim Pnt(1 To lngPaperCount)
'Pad variable to accept 64 bytes for each paper name.
strPaperNameList = String(Number:=64 * lngPaperCount, Character:=0)
'Get string buffer of paper names supported by printer.
lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, lpPort:=strDevicePort, iIndex:=DC_PAPERNAMES, lpOutput:=ByVal strPaperNameList, lpDevMode:=DEFAULT_VALUES)
'Get array of paper numbers supported by printer
lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, lpPort:=strDevicePort, iIndex:=DC_PAPERS, lpOutput:=intPaperNumber(1), lpDevMode:=0)
'get point list of paper sizes for each paper
lngPaperCount = DeviceCapabilities(lpsDeviceName:=strDeviceName, lpPort:=strDevicePort, iIndex:=DC_PAPERSIZE, lpOutput:=Pnt(1), lpDevMode:=0)
'List available paper names.
strMsg = "Paper available for " & strDeviceName & vbCrLf
For lngCounter = 1 To lngPaperCount
' Parse a paper name from string buffer.
strPaperName = Mid(String:=strPaperNameList, Start:=64 * (lngCounter - 1) + 1, Length:=64)
intLength = VBA.InStr(Start:=1, String1:=strPaperName, String2:=Chr(0)) - 1
strPaperName = Left(String:=strPaperName, Length:=intLength)
strTemp = intPaperNumber(lngCounter) & vbTab & strPaperName
intTemp = Len(strTemp)
strTemp = strTemp & String(40 - intTemp, " "
' Add bin name and number to text string for message box.
strMsg = strMsg & vbCrLf & strTemp & vbTab & "X=" & Pnt(lngCounter).X & vbTab & "Y=" & Pnt(lngCounter).Y
Next lngCounter
' Show paper bin numbers and names in message box.
'MsgBox Prompt:=strMsg
Debug.Print strMsg
'Printer.Print formMain.Combo1.Text
'Printer.Print strMsg
'Printer.EndDoc
GetPaperNames_End:
Exit Function
GetPaperNames_Err:
MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
Title:="Error Number " & Err.Number & " Occurred"
Resume GetPaperNames_End
End Function
[/tt]
I think that is what you are asking for. (and I think I got it working right on win2kSP2 VB6SP5).
There is a whole lot more info you can get with the DeviceCapabilities API.
Good Luck