Calling the printer in DOS console

This is a discussion on Calling the printer in DOS console within the C++ Programming forums, part of the General Programming Boards category; I would like to print files in one of my own programs, but i dont have a clue on how ...

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Calling the printer in DOS console

    I would like to print files in one of my own programs, but i dont have a clue on how to make the printer do that.
    int there like a Print("This file", "on this printer"); ?
    Is there a way to even do that without coding a bunch of
    #define lexmarkz31 00x888ddd
    #define lexmarkz33 00x000002
    ??

    thanks in advance!
    This war, like the next war, is a war to end war.

  2. #2
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Thanks. But that looks like normal C functions to me.

    I can understand a good bit of C++, but i can't stand C's printf("%this %that %thisnadthat");
    it always confuses me.

    Are there any C++ style functions for that?
    This war, like the next war, is a war to end war.

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I've had this question too, but never asked it because I don't need it with what I'm doing right now... so there isn't any simple system calls or anything?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    nope, no system calls. It's like a stream/port
    just stream the info through and when your done, feed the form '\f'

    ex:
    Code:
    #include <iostream.h>
    #include <fstream.h>
    int main()
    {
    	ofstream printer("LPT1:"); 
    	printer<<"This comes out of the printer"<<endl;
    	printer<<"\f";//form feed (end the page)
    	return 0;
    }
    //Don't know where your printer is?
    //Press Ctrl+P RIGHT NOW and on the right side usually in a Parenthesis it tells you
    //Depending on OS...
    // LPT1
    // LPT2
    // PRNT
    // Ne00
    // etc.
    -LC
    Last edited by Lynux-Penguin; 07-28-2003 at 10:43 PM.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

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

    Unhappy My (bad) experiences...

    Check your printer's documentation / website to see if it works with DOS. Or, open a DOS window and type DIR>PRN. (That's a DIRectory command, with the output re-directed to the printer.)

    I have on of those "cheap windows GDI printers" and it ONLY works with the Windows API functions via it's windows driver. You can't send it straight ASCII.

    I'll bet that all USB printers require that you print through a driver too.

    My old printer worked with true-DOS applications running in a DOS-Window, but I was NEVER able to print from a Windows console application. I had to use the Windows API functions... "Get Handle To Device Context" [GetHDC() ???] ... and all that stuff I can't remember off the top of my head...

  6. #6
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I have LPT1:

    Andd windows programming? fuhggehttuhboutit

    Unles i can get a good tutor on it... websites themselves NEVER help me
    This war, like the next war, is a war to end war.

  7. #7
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Code:
    #include <iostream.h>
    #include <fstream.h>
    int main()
    {
    ofstream printer("LPT1:");
    printer<<"This comes out of the printer"<<endl;
    printer<<"\f";//form feed (end the page)
    return 0;
    }
    just din't do anything at all...
    This war, like the next war, is a war to end war.

  8. #8
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I tried PRN, and no, no file was created.
    This war, like the next war, is a war to end war.

  9. #9
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    that's really REALLY strange.
    btw- nice website
    -LC
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  10. #10
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    does nothing at all...

    is there a printfile fuction to print a made and saved text file though?
    This war, like the next war, is a war to end war.

  11. #11
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    "BTW - Nice website"....
    talking about mine?
    Thanks.
    We had a better one, but it was deleted for some reason....
    This war, like the next war, is a war to end war.

  12. #12
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Originally posted by Blizzarddog
    I have LPT1:

    Andd windows programming? fuhggehttuhboutit

    Unles i can get a good tutor on it... websites themselves NEVER help me
    Get books. A 3 or 4 page tutorial can't replace an 800 page book, it's simply not possible.

  13. #13
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    got any suggestions?
    EASY books to learn from?
    This war, like the next war, is a war to end war.

  14. #14
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Correct...
    but its not even making a file...
    This war, like the next war, is a war to end war.

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

    Books...

    There are no really easy books, beacuse, as you know, Windows programming is not easy!

    The difficulty of Windows programming relates to the "overhead" of creating a resizable window that responds to mouse clicks, etc. For example, "Hello World" in Windows is something like 50-75 lines of code. The other thing that makes it difficult is the number of Windows API functions... maybe over a thousand... maybe a few thousand (?)

    When you feel ready, Charles Petzold's "Programming Windows" is generally considered the best book on the subject.

    Herhert Schildt's "Programming Windows 2000 From The Ground Up" is very similar to Petzold's.

    These books don't require that you know anything about Windows programming to get started, and, they don't use any advanced C++ features, or complicated algorithms. I beleive they only use C. (I'm not absolutely sure because I have the older versions of these books.) They focus on using the Windows API functions.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. programing in DOS?
    By k1ll3r in forum C++ Programming
    Replies: 41
    Last Post: 05-31-2006, 05:17 AM
  2. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 10:59 PM
  3. ASCII Grafix Dos Console
    By Blizzarddog in forum Game Programming
    Replies: 19
    Last Post: 01-20-2003, 09:41 AM
  4. File systems?? (Winxp -> DOS)
    By Shadow in forum Tech Board
    Replies: 4
    Last Post: 01-06-2003, 09:08 PM
  5. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21