Board index » delphi » How to execute DOS-Program from Delphi

How to execute DOS-Program from Delphi

Hi all!

I want to execute a dos-program from Delphi.
Currently I'm using WinExec() to do it, but it is opening a dos-box and
running the
program in it.
Is there a way, to execute the program "directly" without a dos-box ( it
is annoying that the user has to quit the dos-box after the program has
terminated)

Thx for answers, bye
     Hseyin

 

Re:How to execute DOS-Program from Delphi


You could only hide it.
Try setting the 'Close on Exit' property not sure how to do it in code
but if you set it in the properties for the master dosprompt
(C:\Windows)
It should work for all (I think)
Another way is to write something out to a file or the registry when
it's done and poll this from the calling program. You could then
send a WMCLOSE message to the dos window
Nick
Quote
huhu wrote:

> Hi all!

> I want to execute a dos-program from Delphi.
> Currently I'm using WinExec() to do it, but it is opening a dos-box and
> running the
> program in it.
> Is there a way, to execute the program "directly" without a dos-box ( it
> is annoying that the user has to quit the dos-box after the program has
> terminated)

> Thx for answers, bye
>      Hseyin

Re:How to execute DOS-Program from Delphi


Create a PIF-file and execute that.
In the pif-file you can specify that it should "close on exit".

huhu <huesey...@gmx.net> skrev i en
nyhedsmeddelelse:3762C8CF.4BBB4...@gmx.net...

Quote
> I want to execute a dos-program from Delphi.
> Currently I'm using WinExec() to do it, but it is opening a dos-box and
> running the
> program in it.
> Is there a way, to execute the program "directly" without a dos-box ( it
> is annoying that the user has to quit the dos-box after the program has
> terminated)

Re:How to execute DOS-Program from Delphi


Greetings... I would like to do the very same thing.

What does your code look like when attached
to a button?

Re:How to execute DOS-Program from Delphi


Try CreateProcess :

 FillChar(StartupInfo,SizeOf(StartupInfo),0);
  StartupInfo.cb := SizeOf(StartupInfo);
  GetDir(0,CurDir);
  if not CreateProcess(nil,'DOSPROG.EXE'
nil,nil,false,NORMAL_PRIORITY_CLASS,nil,
                    PChar(CurDir),StartupInfo,ProcessInfo) then...

Gunnar Martensen

huhu skrev i meddelelsen <3762C8CF.4BBB4...@gmx.net>...

Quote
>Hi all!

>I want to execute a dos-program from Delphi.
>Currently I'm using WinExec() to do it, but it is opening a dos-box and
>running the
>program in it.
>Is there a way, to execute the program "directly" without a dos-box ( it
>is annoying that the user has to quit the dos-box after the program has
>terminated)

>Thx for answers, bye
>     Hseyin

Re:How to execute DOS-Program from Delphi


Uses ShellApi;

procedure TForm1.Button1Click(Sender: TObject);
var
  Prog, Dir, Parm: String;
begin
  Prog := 'c:\temp\mypif.pif';
  Dir := ExtractFilePath(Prog);
  Parm := '';
  ShellExecute(Self.Handle, 'open', PChar(Prog), PChar(Parm), PChar(Dir),
SW_SHOWNORMAL);
end;

PBBS90210 <pbbs90...@aol.com> skrev i en
nyhedsmeddelelse:19990617031447.20180.00000...@ng-fv1.aol.com...

Quote
> Greetings... I would like to do the very same thing.

> What does your code look like when attached
> to a button?

Other Threads