Re: Printer resolution under XP

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: MikeD (nobody_at_nowhere.edu)
Date: 08/19/04


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



Relevant Pages

  • Re: Migrating from VB6 and Printer object
    ... You can use the GetPrinter API call to get all the information (such as Port name) - e.g. ... ByRef phPrinter As Int32, _ ... Public pServerName As String ... Dim dmOut As New DEVMODE ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Serial port error statistics - any comparable data?
    ... Alas - the port in question is the native legacy motherboard port. ... The "cluster" in all the cases observed is the loss of exactly one character, ... "The quick brown fox jumps over the lazy dog 0123456789" ... the string from a port unblocked with fcntl - and the throw away python ...
    (comp.lang.python)
  • Re: Problem with changepassword webcontrol
    ... I'm guessing there is some mismatch in the username string used to find the user somehow. ... It needs to know what port to attempt an LDAP password change on because by default it tries this on AD LDAP with SSL and your server is not listening on that port. ... it is likely going to attempt a clear text password change so make sure you have LDS configured to allow that. ... (String eventArgument) ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: [PATCH] virtio_console: Add support for multiple ports for generic guest and host communication
    ... ret = write); ... updating magic tables of guest code and expands cleanly - yes? ... Can you tell me how this could work out -- each console port could have ... a "role" string associated with it (obtainable from the invoking qemu ...
    (Linux-Kernel)
  • Re: How to convert array to string, and vice versa
    ... and converting it to a single string: ... then I have a string I can write to the database record. ... information about the port optics. ... to have a set of port-records, pointing to the interface card. ...
    (comp.lang.php)