Posted on 2003-03-25
Medium Priority
Last Modified: 2010-04-04
How can I pass a file name (e.g. a.doc, a.htm, a.xls or a.htm) to a console application and open it with proper application ?

Question by:andrewyu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Motaz earned 120 total points
ID: 8204347
if you mean console application written with Delphi, then you can use ParamStr(1) to read parameters that has been called like:

MyConsole.exe "c:\my documents\first.doc"

In your console application add ShellApi to uses caluse and write this code to open that file with MS-Word or the default .doc application:

ShellExecute(nil, 'open', PChar(ParamStr(1)), nil, nil, sw_Normal);

I'm not sure about sw_Normal, may be sw_ShowNormal, also you can put numbers such as 0, 1, 2 instead of that constants.


Author Comment

ID: 8204643
Thank you very much !


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question