Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open '.exe' file in Delphi pascal

Status
Not open for further replies.

11111977

Programmer
Joined
Oct 15, 2003
Messages
1
Location
FR
I'd like to open an '.exe' file in Delphi Pascal on a buttonclick. do anybody have a code example?
thank you
 
Windows API CreateProcess does the trick.

Here is a simple wrapper for it

procedure SHCreateProcess(const ACommandLine:string);
var
StartupInfo:TStartupInfo;
ProcessInformation:TProcessInformation;
begin
FillChar(StartupInfo,Sizeof(StartupInfo),0);
FillChar(ProcessInformation,Sizeof(ProcessInformation),0);

if CreateProcess(nil,pchar(ACommandLine),
nil,nil,false,0,nil,nil,StartupInfo,ProcessInformation)then begin
CloseHandle(ProcessInformation.hProcess);
CloseHandle(ProcessInformation.hThread);
end;
end;
 
or a simple

Code:
ShellExecute(Handle, 'open', PChar([Filename here]), nil, nil, SW_SHOWNORMAL);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top