请问诸位高手,我想执行当前目录下的一个EXE文件,需要怎样做才可以实现?
谢谢。

解决方案 »

  1.   

    uses shellapi
    ShellExecute(0,'open','calc.exe','','', SW_SHOW );
      

  2.   

    ShellExecute(    HWND hwnd, // handle to parent window
        LPCTSTR lpOperation, // pointer to string that specifies operation to perform
        LPCTSTR lpFile, // pointer to filename or folder name string
        LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters 
        LPCTSTR lpDirectory, // pointer to string that specifies default directory
        INT nShowCmd  // whether file is shown when opened
       );查查help下面的WINDOWS SDK
      

  3.   

    先用path=ExtractFilePath(Application.ExeName));得到当前应用程序所在的路径然后run=path+"文件名";最后是运行:WinExeC,最简单,但是它只能调用可执行程序;
      ShellExecute,可以启动某一可执行程序,也可以启动与你给出的文件相关联的应用程序;
      ShellExecuteEx,和上两者相似,不过传递的参数不一样。
      

  4.   

    先用path=ExtractFilePath(Application.ExeName));得到当前应用程序所在的路径然后run=path+"文件名";最后是运行:WinExeC,最简单,但是它只能调用可执行程序;
      ShellExecute,可以启动某一可执行程序,也可以启动与你给出的文件相关联的应用程序;
      ShellExecuteEx,和上两者相似,不过传递的参数不一样。
      

  5.   

    ExeFileName :=ExtractFilePath(Paramstr(0))+'exe文件名'
    例:E:\data\mm.exe
    执行:
    winexec(ExeFileName,SW_SHOWDEFAULT);
      

  6.   


     path:=ExtractFilePath(Application.ExeName)+'abc.exe';  winexec(path);
      

  7.   

    WinExec(lpCmdLine:PChar;uCmdShow:Cardinal);
      

  8.   

    winexec;
    shellexceute;
    shellexceute 需要加入shellipa单元
      

  9.   

    uses shellapi
    ShellExecute(handle,'open','readme.txt','','', SW_SHOWNORMAL);
      

  10.   

    不好意思,对此帖进行更正,我是想执行当前目录下的一个文件夹下的EXE文件,试了几次总是不行抱歉。
      

  11.   

    procedure TFDemo.Button2Click(Sender: TObject);
    var
      path:PChar;
    begin
      //ce为当前目录下的那个文件夹
      path:=Pchar(ExtractFilePath(Application.ExeName)+'ce\calc.exe');
      ShellExecute(handle,'open',path,'','', SW_SHOWNORMAL);
    end;
      

  12.   

    请uses shellapi程序调试通过,calc.exe为ce目录下的计算器程序
      

  13.   

    请uses shellapi才能编译ShellExecuteprocedure TFDemo.Button2Click(Sender: TObject);
    var
      path:PChar;
    begin
      //ce为当前目录下的那个文件夹
      path:=Pchar(ExtractFilePath(Application.ExeName)+'ce\calc.exe');
      ShellExecute(handle,'open',path,'','', SW_SHOWNORMAL);
    end;
    程序调试通过,calc.exe为ce目录下的计算器程序
    那个可执行目录你可以自己定义
      

  14.   

    请问如何用SHELLAPI编译SHELLEXECUTE
      

  15.   

    你只要把shellapi加到uses 列表中
    就可以编译通过!
      

  16.   

    不会吧
    如下
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,shellapi;//就加在这边就OK了