Also how do i send text to my printer without using APIs

This is a discussion on Also how do i send text to my printer without using APIs within the C++ Programming forums, part of the General Programming Boards category; i am using VC6 Also how do i send text to my printer without using APIs I have tried FILE ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    12

    Also how do i send text to my printer without using APIs

    i am using VC6

    Also how do i send text to my printer without using APIs

    I have tried
    FILE *fp=fopen("lpt1", "w");
    and
    FILE *fp=fopen("lpt1:", "w");
    it gave me a runtime error

  2. #2
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    I think you can do

    fprintf("LPT1","Hello, world!");

    Not sure though

    Oskilian

  3. #3
    Ted
    Ted is offline
    Registered User
    Join Date
    Aug 2001
    Posts
    52
    I've used this in C++:
    Code:
            const char EJECT = 0x0c;  // printer page eject command
            ofstream print;
    
            print.open( "LPT1" );
    
    and this in C:
    
            FILE *prnPtr;
    
            prnPtr = fopen("lpt1", "w");
    expect problems with bubblejet and some laser printers.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    12
    it is not working. it is returning NULL
    I am using VC++

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    > it is returning NULL
    Yeah, so the next step is find out why

    Code:
    FILE *fp=fopen("lpt1", "w"); 
    if ( fp == NULL ) {
      perror( "No printer" );
      exit( 1 );
    }
    Do this then post the error message, if it isn't already obvious what is going wrong.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    12
    there is a printer connected to my computer.
    have you tried it on there system.

  7. #7
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    have you tried "PRN" instead of "LPT1" ?
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Let's hope it is actually connected to lpt1 and not a USB port.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    12
    ya man, it is connected to a usb

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    12
    my printer is connected to the usb port.
    do you how to open a printer connected to the usb port

  11. #11
    Registered User
    Join Date
    Apr 2002
    Posts
    12

    Also how do i send text to my printer without using APIs

    Also how do i send text to my printer without using APIs
    my printer is connected to a usb port

  12. #12
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    I think you're going to find that very difficult. Very difficult indeed. One thing you can try (I don't know how likely it is this will work for you, but it is possible, at least on some versions of Windows)...

    [list=a][*]Install file & printer sharing[*]Share your USB printer[*]DROP to a DOS prompt and type "net use lpt1: \\<computer_name>\<printer_name>"[*]Then use the output to LPT1, as posted in your other thread[/list=a]
    Computer name is the network name of your PC
    Printer name is what ever name you give when sharing your printer.

    You may find you need to push form feed characters to your printer in order to get it to spit out any text you have sent it, if you haven't sent it a full page.

    You may also be able to look in your printer manual for other escape sequences to change fonts or other settings.

    Good luck.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  13. #13
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    or you could do like salem says and post the error message.
    What make of printer?
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  14. #14
    Unregistered
    Guest
    Lexmark Z12

  15. #15
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by C_Coder
    or you could do like salem says and post the error message.
    What make of printer?
    err.... it's connected to a USB port, hence it's not known to the system via ltp1. The error message is pretty irrelevant at this point
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New Project, text game, design stage.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 05-23-2007, 06:39 AM
  2. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-31-2004, 11:52 AM
  3. Small HTML question
    By Thantos in forum Tech Board
    Replies: 4
    Last Post: 12-28-2003, 11:37 PM
  4. Email attachment via smtp - how?!
    By lucky760 in forum C++ Programming
    Replies: 2
    Last Post: 07-04-2002, 07:59 PM
  5. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM

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