|
-
Feb 21st, 2001, 11:07 AM
#1
Thread Starter
Junior Member
How can i get Printer Available Trays???? And all that information associated to a printer?
Thanks,
-
Feb 22nd, 2001, 06:40 PM
#2
Addicted Member
You can use the DeviceCapabilities API call.
-
Feb 23rd, 2001, 11:08 AM
#3
Thread Starter
Junior Member
DeviceCapabilities API
Thanks,
But can someone give me an example of how to use this API? (DeviceCapabilities)
-
Feb 23rd, 2001, 05:37 PM
#4
Addicted Member
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.
-
Feb 28th, 2001, 11:53 AM
#5
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|