举个例子好吗,比方说要启动f:\office\word.exe,该怎么写啊

解决方案 »

  1.   

    首先使用单元: Uses ShellApi;使用其中涵数:ShellExecute();
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    uses shellapi;begin
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     shellapi('F:\Microsoft Office\Office10\access.exe');
    end;end.
    编译每通过
      

  3.   

    winexec('f:\office\word.exe',SW_SHOW);UINT WinExec(    LPCSTR lpCmdLine, // 命令行的地址
        UINT uCmdShow  // 新应用程序的窗口式样
       );命令行的地址:就是要执行的EXE的全路径!(如:c:\command.com)新应用程序的窗口式样:
    hWndIdentifies the window. nCmdShowSpecifies how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow
     is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values: Value Meaning
    SW_HIDE Hides the window and activates another window.
    SW_MAXIMIZE Maximizes the specified window.
    SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the Z order.
    SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
    SW_SHOW Activates the window and displays it in its current size and position. 
    SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. 
    SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
    SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
    SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active.
    SW_SHOWNA Displays the window in its current state. The active window remains active.
    SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
    SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
      

  4.   

    先在uses里加入shellapi
    然后打ShellExecute(Handle,'open',PChar('f:\offices\word.exe',nil,nil,SW_SHOWNORMAL);
      

  5.   


    来晚了
    shellexecute(handle,nil,'f:\offices\word.exe',nil,nil,sw_shownormal);winexec('')很简单的了自己看看吧
      

  6.   

    还有一个最麻烦的
    var
      sCommandLine: string;
      bCreateProcess: boolean;
      lpStartupInfo: TStartupInfo;
      lpProcessInformation: TProcessInformation;
    begin
      sCommandLine := 'f:\offices\word.exe';
      bCreateProcess := CreateProcessA(nil, PChar(sCommandLine),
        nil, nil, True, NORMAL_PRIORITY_CLASS, nil, nil,
        lpStartupInfo, lpProcessInformation);
    end;