PC Review


Reply
Thread Tools Rate Thread

Detect all paper size the printer supports

 
 
=?Utf-8?B?VHJhbiBIb25nIFF1YW5n?=
Guest
Posts: n/a
 
      17th Apr 2006
Hi,
Is it possible to detect all paper that given printer support? For example,
I would like to check whether my printer can print A4 and A3 or not.

Regards
Tran Hong Quang
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      18th Apr 2006
"Tran Hong Quang" <(E-Mail Removed)> wrote in
message news:E2CE520D-0EDC-4B3B-B714-(E-Mail Removed)
> Hi,
> Is it possible to detect all paper that given printer support? For
> example, I would like to check whether my printer can print A4 and A3
> or not.


I've never tried it before, but apparently you can call the
DeviceCapabilities API function to find this out. The code would be
something like this, which I modified from the API guide provided by
AllAPI.Net:

'----- start of code -----
Private Const DC_PAPERNAMES = 16

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

Sub GetPaperNames()

' This procedure prints the supported paper sizes, by name, to the
' Immediate window. Modify as needed.

Dim Ret As Long
Dim PaperSizes() As Byte
Dim Cnt As Long
Dim AllNames As String
Dim lStart As Long, lEnd As Long

'Retrieve the number of available paper names
Ret = DeviceCapabilities( _
Printer.DeviceName, _
"LPT1", _
DC_PAPERNAMES, _
ByVal 0&, _
ByVal 0&)

'resize the array
ReDim PaperSizes(1 To Ret * 64) As Byte

'retrieve all the available paper names
Call DeviceCapabilities( _
Printer.DeviceName, _
"LPT1", _
DC_PAPERNAMES, _
PaperSizes(1), _
ByVal 0&)

Debug.Print "Supported papersizes:"

'convert the retrieved byte array to a string
AllNames = StrConv(PaperSizes, vbUnicode)

'loop through the string and search for the names of the papers
Do
lEnd = InStr(lStart + 1, AllNames, Chr$(0), vbBinaryCompare)
If (lEnd > 0) And (lEnd - lStart - 1 > 0) Then
Debug.Print Mid$(AllNames, lStart + 1, lEnd - lStart - 1)
End If
lStart = lEnd
Loop Until lEnd = 0

End Sub
'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printer Paper size =?Utf-8?B?Q2xpZmY=?= Windows XP Print / Fax 2 4th Sep 2006 08:29 AM
printer paper size =?Utf-8?B?YW50aG9ueQ==?= Microsoft Dot NET 0 16th Oct 2005 10:29 PM
Printer paper size Charest Windows XP Print / Fax 2 19th Sep 2003 04:53 PM
printer paper size Jason Windows XP Print / Fax 1 11th Aug 2003 08:56 PM
Edit the paper size from a printer Bailat Windows XP Print / Fax 1 1st Jul 2003 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 AM.