• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

EXEcution a program in delphi with specific title

hi,
i wanna run a dos program from my app in delphi with a command like winexec or other but
i wanna that put my title on the window that profram run in it. for example run cmd command with title HELO
is there any wy?
tank you
0
mhyassin
Asked:
mhyassin
1 Solution
 
mikelittlewoodCommented:
Here is the command to run a dos app where Edit1 is holding the command you want to run.
As to how you put a title on the dos caption bar Im not too sure but will keep looking for you

WinExec(PChar('COMMAND.COM /C ' + Edit1.Text), SW_SHOWNORMAL);
0
 
pcsentinelCommented:
Heres how

say you have a batch file called t.bat in the root of C

add this code

var
      lStartupInfo: TStartupInfo;
      lProcessInfo: TProcessInformation;
      lSuccess: boolean;
begin
  try
    FillChar(lStartupInfo, SizeOf(TStartupInfo), #0);
    lStartupInfo.lpDesktop:=pChar('winsta0\default');
    lStartupInfo.cb := SizeOf(TStartupInfo);
    lStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
    lStartupInfo.wShowWindow := SW_SHOW;
    lStartupInfo.lpTitle:=pChar('Test Title');   <------put the title you want here
    lSuccess := CreateProcess(nil,PChar('COMMAND.COM /C ' + '"c:\t.bat"'), nil, nil, False, <substitute your prog path and name here
      NORMAL_PRIORITY_CLASS, nil, nil, lStartupInfo, lProcessInfo);
    if lSuccess then
    begin
      WaitForInputIdle(lProcessInfo.hProcess, INFINITE);
      CloseHandle(lProcessInfo.hThread);
      CloseHandle(lProcessInfo.hProcess);
    end
    else
      Messagedlg('Unable to Launch' ,mtError,[mbok],0);
  except
    Messagedlg('Error launching Application',mtError,[mbok],0);
  end;
  Application.Terminate;

end;

regards


0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now