就是知道路径的字符串,存储在str1中,调用哪个函数能运行该路径的文件呢?

解决方案 »

  1.   

    var
      str1: String;
    begin
      //……
       if FileExists(str1) then
        ShellExecute(0, 'Open', PChar(str1), nil, nil, SW_SHOW)
      else
        MessageBox(0, PChar(str1+' 指定的文件不存在。'), '提示', MB_OK);
    end;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  2.   

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

  3.   

    ShellExecute不能编译呀,
    Winexec里面的参数填什么好呢?
    另外,我的str1里面包含了路径和文件名的。
      

  4.   

    Winexec我已经搞定了。
    就是ShellExecute不能编译,好像ShellExecute是VB里面的函数吧?
      

  5.   

    procedure TFDemo.Button2Click(Sender: TObject);
    var
      path:pChar;
      str1:string;
    begin
      //ce为当前目录下的那个文件夹
      str1:='路径';
      path:=Pchar(str1);
      ShellExecute(handle,'open',path,'','', SW_SHOWNORMAL);
    end;
    请uses shellapi才能   编译ShellExecute