Re: Printer resolution under XP
From: MikeD (nobody_at_nowhere.edu)
Date: 08/19/04
- Next message: Randy Birch: "Re: Printer resolution under XP"
- Previous message: Peter Huang: "Re: Explorer.exe issue"
- In reply to: Carlos Domingos: "Printer resolution under XP"
- Next in thread: Randy Birch: "Re: Printer resolution under XP"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 22:08:55 -0400
"Carlos Domingos" <bigpig@webmail.co.za> wrote in message
news:eKtkeaWhEHA.632@TK2MSFTNGP12.phx.gbl...
> I need to know the printer resolution (local printer).
> Under Win 98se using DocumentProperties() or DeviceCapabilities() I do get
> reliable results.
> However the same code under XP crashes. Eg:
>
> ...
> Ret = DeviceCapabilities(Printer.DeviceName, Printer.Port, 13, ByVal
0&,
> ByVal 0&)
> ReDim PResolutions(1 To Ret) As Integer
> Call DeviceCapabilities(Printer.DeviceName, Printer.Port, 13,
> PResolutions(1), ByVal 0&)
> Me.Print "Supported resolutions:"
> For Cnt = 1 To Ret
> Me.Print Str$(PResolutions(Cnt))
> Next
More info....
I decided to try your code under Windows 2000. Some interesting things
occured. First, did you confirm the port is correct? I ask this because
Printer.Port (for me) was "Ne00:" That's NOT the right port. I have a USB
printer, and the actual port name (as least as indicated in the printer's
properties dialog box) is "USB001". However, this DIDN'T cause a crash. The
function called failed (it returned -1) so I got a runtime error on the next
statement trying to ReDim the array. So, then I tried this:
Ret = DeviceCapabilities(Printer.DeviceName, "USB001", 13, vbNullString,
ByVal 0&)
but that also returned -1.
When you say "crashes" do you mean the app actually crashes, or are you just
getting a runtime error that maybe you're not handling?
BTW, the declaration I used was this:
Private Declare Function DeviceCapabilities Lib "winspool.drv" Alias
"DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String,
ByVal iIndex As Long, ByVal lpOutput As String, lpDevMode As Long) As Long
Now, I also noticed that the lpOutput is declared As String (that's why I
used vbNullString) and in the SDK, this parameter is LPTSTR. Therefore, the
array might need to be of type String. However, since the first call (for
me) returns -1 (where I'm passing a null), there's something else wrong with
my code. It seems to be the printer port.
I don't know if any of this information is useful or not, but I just thought
I'd let you know my results.
Mike
Mike
- Next message: Randy Birch: "Re: Printer resolution under XP"
- Previous message: Peter Huang: "Re: Explorer.exe issue"
- In reply to: Carlos Domingos: "Printer resolution under XP"
- Next in thread: Randy Birch: "Re: Printer resolution under XP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|