Solved

Using WinExec to launch a program

Posted on 1997-09-17
8
359 Views
Last Modified: 2010-04-04
How do I open an editor with a specific textfile loaded.
I have tried
WinExec('EditorProgram.Exe, Myfile.txt', SW_SHOW);
but it does'nt work.
0
Comment
Question by:rainbowsoftware
[X]
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
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345325
mayby remove comma ? and try :
WinExec('EditorProgram.Exe Myfile.txt', SW_SHOW);
and of course you must insert all with full path name.

WinExec('c:\tmp\EditorProgram.Exe c:\doc\Myfile.txt', SW_SHOW);
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1345326
try this:

uses shellapi;
.
.
shellexecute(handle,'open','c:\doc\Myfile.txt','','',sw_show);

this will open the text file by the editor program associated with the text file.
0
 

Author Comment

by:rainbowsoftware
ID: 1345327
Sorry it does'nt work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1345328
try this:
shellexecute(handle,'open','c:\...\EditorProgram.Exe','c:\...\Myfile.txt','',sw_show);
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345329
What program you try running ? and
WinExec is a function What is the result ?
0
 

Author Comment

by:rainbowsoftware
ID: 1345330
I have created my own Editor and try to open a textfile in my editor.
And I have also been trying to open a file in the Delphi Demo program Richedit,
but didn't succeed ( Richedit application is a Demo on the Delphi 2 CD)

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345331
Do you'r program parsing Parameters ?

example :
for i:=0 to ParamCount do
  st := ParamStr(i);

You must do this.

The Simples way is to place in OnShow of MainForm the code to load file which have name = ParamStr(1)

You probably have a function for load file so you must call them with ParamStr(1).
0
 

Author Comment

by:rainbowsoftware
ID: 1345332
Thanks for yor answer, I found the solution with Params.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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