Thread: USB printing

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    23

    USB printing

    Is there any way ina console c++ program to print with a printer that runs off usb

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    ... Not sure

    Heck, I couldn't even print via the parallel port! (From a windows console application.)

    You might have to use a WinAPI function and the windows driver.
    I don't remember exactly how to do this... and I've never tried it from a console application... But you have to "get a handle to the device context" and then print to the "device context" I think there's a TextOut() function and a DrawText() function.

    Once you're in the windows world, It doesn't matter if your printer is parallel, USB, network, etc.

    Some printers, such as my Canon, can't even print from DOS! That is, you can't simply send ASCII to them. They require a driver.

    [EDIT]
    Well, I looked it up in Petzold last night, and his "bare-bones" printer example is a full page long! I'm afraid it wouldn't be much help without the text, and it might be a copyright violation to post it.
    Last edited by DougDbug; 03-18-2003 at 12:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. printing to usb port
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 03-05-2002, 12:43 PM
  2. Printing Via Usb
    By LKOFMAN in forum C Programming
    Replies: 0
    Last Post: 12-24-2001, 08:24 PM
  3. Printing Via Usb
    By LKOFMAN in forum C Programming
    Replies: 0
    Last Post: 12-23-2001, 08:31 PM
  4. Printing via USB port
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-31-2001, 04:19 PM
  5. Printing to USB
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 10-19-2001, 12:36 PM