各位大哥:怎样能通过一个按钮调用已经存在的exe或bat文件,使其能过通过点击该按钮运行这些文件。谢谢

解决方案 »

  1.   

    winexec;
    shellexecute;
    这种问题论坛每天都有问的,你看下
      

  2.   

    uses shellapi
    ShellExecute(Handle,'open',PChar('c:\test\app.exe'),nil,nil,SW_SHOW);Winexec(pchar('noptepad'),sw_restore);
      

  3.   

    uses ShellAPI;
    ShellExecute(Handle, 'open', PChar(你需要调用的EXE或者BAT文件的路径), nil,nil,SW_SHOW);搞定
      

  4.   

    要想更好控制用此
    //执行处部可执行文件
    Function LaunchApp(pExePath,WorkDir:String;ShowWindow,WaitFlag:Boolean):Boolean;
    var ExePath : array[0..512] of char;
        StartupInfo:TStartupInfo;
        ProcessInfo:TProcessInformation;
    begin
      StrPCopy(exePath, pExePath);
      FillChar(StartupInfo,Sizeof(StartupInfo),#0);
      StartupInfo.cb := Sizeof(StartupInfo);
      StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
      if ShowWindow then
        StartupInfo.wShowWindow := 1
      else
        StartupInfo.wShowWindow := 0;
      if not CreateProcess(nil,
                          ExePath,
                          nil,
                          nil,
                          false,
                          CREATE_NEW_CONSOLE or
                          NORMAL_PRIORITY_CLASS,
                          nil,
                          nil,
                          StartupInfo,
                          ProcessInfo) then  begin
        Result:=False;
        Exit;
      end else begin
        if WaitFlag then
          WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
        Result:=True;
      end;
    end;
      

  5.   

    Winexec(pchar('noptepad'),sw_restore);什么意思?
      

  6.   

    Function LaunchApp(pExePath,WorkDir:String;ShowWindow,WaitFlag:Boolean):Boolean;这个函数用到哪里?
      

  7.   

    哎呀,csdn上这种问题不知道解答了多少遍啊
    查一下了
    uses ShellAPI;
    ShellExecute(Handle, 'open', PChar(你需要调用的EXE或者BAT文件的路径), nil,nil,SW_SHOW);
      

  8.   

    如LaunchApp(TempPath+'WinRar.exe e '+TempPath+'FileUp.Rar '+TempPath+' -o+ -y ','',False,True);