printing a text file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: printing a text file

Hybrid View

  1. #1
    Join Date
    Apr 2009

    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.


  2. #2
    Join Date
    Jun 2004

    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.

    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
    Join Date
    Oct 2002
    Timisoara, Romania

    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.

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center