CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    2

    printing a text file

    I need to print a text file automatically with the default printer (I mean print on paper, not print to the screen). I've found a bunch of disorganized information everywhere about how to do this, but none of it really helps. I was wondering if someone could give me an example function for printing "example.txt".

    If anybody knows any tutorials, it would also be nice to hear about them.

    Thanks!

  2. #2
    Join Date
    Jun 2004
    Posts
    1,329

    Re: printing a text file

    I'm not in my office at the moment, however there is a way to get notepad to print a file directly without displaying it.


    Code:
    char* pFileName = "c:\\temp.txt";
    
    	ShellExecute(this->m_hWnd,"open","Notepad.exe", pFileName, "c:\\", SW_SHOW);
    I do the above in my apps.

    Look up the in the internet how to get Notepad.exe to print a file in the background, I think there is a way to do that.

    If not when I get back to my office I'll post some code to open up the print engine and print a text file.
    Rate this post if it helped you.

  3. #3
    cilu's Avatar
    cilu is offline Moderator/Reviewer/MS MVP Power Poster cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+)
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,349

    Re: printing a text file

    Well, that should only open the file. But if you used "print" instead of "open" for the second argument to ShellExecute(), then that should print the file.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width