I have run program with command-line parameters. How can i wait for it to finish running?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Compile and build with single command line Java (L
- Best way to implement MVVM bindings (View <-> V
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- How to update command line output?
- HelpInsight documentation in Delphi 2007
- How to execute another python script from your scr
If I understand your question correctly, you want to execute program in command-line and capture its output in your application rather than in console window. To do so, you can read the output using pipes. Here is an example source code:
Capture the output from a DOS (command/console) Window
If what you want is to execute a command-line executable, and get the response that this exe writes to the console, the easiest way could be to call the exe from a batch file and redirect the output to another file using
>
, and then read that file.For example, if you need to execute the "dir" command and get its output you could have a batch file called
getdir.bat
that contains the following:you could exec that batch file using the API function ShellExecute. You can read about it http://delphi.about.com/od/windowsshellapi/a/executeprogram.htm
Then you can read output file, even using something like a TStringList:
This is my answer : (Thank you all)
Using DSiWin32:
Ok, getting the command-line parameters, you use
ParamCount
: returns the number of parameters passed to the program on the command-line.ParamStr
: returns a specific parameter, requested by index. Running Dephi Applications With ParametersNow, if what you meant is reading and writing to the console, you use
WriteLn
: writes a line of text to the console.ReadLn
: reads a line of text from the console as a string. Delphi Basics