Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.