Results 1 to 7 of 7

Thread: Printing direct to USB printer

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    7

    Printing direct to USB printer

    We have an old VB6 app that interfaces to printers directly through LPT ports. I'm trying to use winspool.drv to print directly to printers attached through USB. It's close to working but not quite as I don't want to spool. That is, when WritePrinter is called, I need the data to be printed straight away; without having to wait for and EndDocPrinter to be called.

    Maybe I don't want to be using winspool.drv, and if that's the case, what should I be using?

    Thanks,

    Bill

  2. #2
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    621

    Re: Printing direct to USB printer

    Look at this KB article: http://support.microsoft.com/kb/154078

    Dick
    Richard Grier, Consultant, Hard & Software
    Microsoft MVP (Visual Basic)

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    7

    Re: Printing direct to USB printer

    Sorry, I should have mentioned that that KB article was my starting point.

    The problem is that data written is still spooled; it doesn't get printed until the page is ended.

    Since I don't want every single text item to be a new page, I've keyed on a few different places in the code where it makes sense to end the page. This application needs to provide a way for the user to tear off some portion of the ticket before the ticket is finally completed.

    Still, it would be better if I could somehow bypass the spooling. Setting the printer property to "Print directly to printer" doesn't seem to do what I had hoped it would do.

    Thanks,

    Bill

  4. #4
    Fanatic Member
    Join Date
    Sep 2009
    Location
    Lakewood, Colorado
    Posts
    621

    Re: Printing direct to USB printer

    The problem is that printer device drivers (when installed) work with the spooler. So, you'd need to be sending data to a device that is not installed, which cannot be done with USB printers.

    Windows' designers, perhaps not irrationally, decided that printers are shared devices -- different applications, running simultaneously, might attempt to print. Thus, the spooler is needed "by design" to avoid the conflict (read: mess) that would occur if applications tried to write to the printer at the same time.

    In general, I don't think you can get there from here.

    Old fashioned LPT port printers could be accessed by writing data directly to the IO ports that control the physical hardware of the LPT port (though the throughput -print speed - is pretty dismal). This simply cannot be done with non-LPT printers.

    Dick
    Richard Grier, Consultant, Hard & Software
    Microsoft MVP (Visual Basic)

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    7

    Re: Printing direct to USB printer

    Still, there should be some simple, rational way to bypass the spooler, if that's what you really want to do. It seems that there is no way to bypass the spooler without writing your own driver.

    Anyway, thanks for your comments. I think I've put this one behind me now and I'm on to bigger cats.

    Bill

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Printing direct to USB printer

    if it is a roll printer you could try setting the paper length to minimum, so each "page" is one or 2 lines, i believe from memory the minimum maybe greater than that, but as most printers now are page printers it just spits out the whole sheet and such features are seldom used, you would probably have to set the printer type to generic /text, for it to ignore any driver settings, then use esc characters, within the text to be printed, to do any formatting or other control

    as it is more than 10 years since i last had a tractor /roll feed printer i can not test any of this,
    if your printer has a centronics input as well as usb, you could get a usb to parallel converter, then write to the lpt port
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    7

    Re: Printing direct to USB printer

    Thanks Pete.

    I guess I'm OK with what I have now. It meets the KISS princable and it works.

    Bill

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