executing other exe files in program - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

executing other exe files in program

hello
please help me to run an exe file in my delphi program
e.g when you click a button that programm would be executed.

Comments

  • zibadianzibadian Posts: 6,349Member
    : hello
    : please help me to run an exe file in my delphi program
    : e.g when you click a button that programm would be executed.
    :
    ShellExecute() in the ShellApi unit. The Windows SDK help files contain more info and Delphi boards contain sample codes.
  • _yilmaz_yilmaz Posts: 150Member
    i think the following procedure does what you want.
    'ProgramName' parameter is the path of your .exe file that you want to execute.

    NOTE: I got it from an article on the web.

    [code]

    procedure ExecNewProcess(ProgramName : String; Wait: Boolean);
    var
    StartInfo : TStartupInfo;
    ProcInfo : TProcessInformation;
    CreateOK : Boolean;
    begin
    { fill with known state }

    FillChar(StartInfo,SizeOf(TStartupInfo),#0);
    FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
    StartInfo.cb := SizeOf(TStartupInfo);
    CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False,
    CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
    nil, nil, StartInfo, ProcInfo);

    { check to see if successful }

    if CreateOK then
    begin
    //may or may not be needed. Usually wait for child processes

    if Wait then
    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
    end
    else
    ShowMessage('Error');

    CloseHandle(ProcInfo.hProcess);
    CloseHandle(ProcInfo.hThread);
    end;
    [/code]

    : hello
    : please help me to run an exe file in my delphi program
    : e.g when you click a button that programm would be executed.
    :

Sign In or Register to comment.