Source Code

Print Document Using Windows Shell

  • anonymous
  • Jan 16' 14
  • Delphi
  • 163
  • 210
  • United States

Documents and files can be printed without a single line of printer support. How? Well, let's let Windows Shell worry about that. This example shows how to print files using the default printing program for that file type. Some file types have such a program registered, others don't. The files that you will be able to print are the ones that have a "Print" command in their pop-up menu.

This is not a good way to print files in your text editor, graphic editor etc. This is what I like to call 'concept code'. You can use it, it works, but it's not a very good idea. This code may come in handy in applications that highly depend on the system Shell. For example: you may have a document viewer that has a "system print" button. You then don't have to worry about adding printing code for all file types. It's the user's problem to register all his/hers files


  ShellAPI, Windows;
// ...
ShellExecute(Application.Handle, 'print', 'Path_to_File', nil, nil, SW_SHOWNORMAL);
  • Tags : print, document, shell
comments powered by Disqus

Related Code

How to get or Set the default printer


Tag Linked