Results 1 to 5 of 5

Thread: Printer Available Trays

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    16

    Question

    How can i get Printer Available Trays???? And all that information associated to a printer?
    Thanks,

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    You can use the DeviceCapabilities API call.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    16

    Question DeviceCapabilities API

    Thanks,
    But can someone give me an example of how to use this API? (DeviceCapabilities)

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Here ya go...

    This example retrieves supported paper sizes. Taken from API Guide.

    Code:
    Const DC_PAPERS = 2
    Private Declare Function DeviceCapabilities Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, lpDevMode As Any) As Long
    
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Ret As Long, PaperSizes() As Integer
        ' First find out how many array fields do we need (by sending 0& for lpOutput and lpDevMode)
        Ret = DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERS, ByVal 0&, ByVal 0&)
        ' Resize array to accept required data
        ReDim PaperSizes(1 To Ret) As Integer
        ' Call the function again, but this time to retrieve the actual data
        Call DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERS, PaperSizes(1), ByVal 0&)
    
        Me.AutoRedraw = True
        Me.Print "Supported papersizes:"
        Dim Cnt As Long
        For Cnt = 1 To Ret
            Me.Print Str$(PaperSizes(Cnt))
        Next
    End Sub

    You can easily get any parameter (look at MSDN's page for available params - link above). First call to DeviceCapabilities returns the number of bytes required for the output data and the second call retrieves the actual data (you just have to resize the buffer array).
    Last edited by Arcom; Feb 23rd, 2001 at 05:42 PM.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    16

    Thumbs up

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width