执行一个外部程序并等待它的完成
Function WinExecExW(cmd,workdir:pchar;visiable:integer):DWORD;
var
 StartupInfo:TStartupInfo;
 ProcessInfo:TProcessInformation;
begin
 FillChar(StartupInfo,SizeOf(StartupInfo),#0);
 StartupInfo.cb:=SizeOf(StartupInfo);
 StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
 StartupInfo.wShowWindow:=visiable;
 if not CreateProcess(nil,cmd,nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo) then
   result:=0
 else
 begin
   waitforsingleobject(processinfo.hProcess,INFINITE);
   GetExitCodeProcess(ProcessInfo.hProcess,Result);
 end;
end;

解决方案 »

  1.   

    FillChar(StartupInfo,SizeOf(StartupInfo),#0);
     StartupInfo.cb:=SizeOf(StartupInfo);
     StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
     StartupInfo.wShowWindow:=visiable;
    可不可以解释一下
      

  2.   

    FillChar(StartupInfo,SizeOf(StartupInfo),#0);
    //用sizeof(StartupInfo)个#0字符来填充StartupInfo字符串
     StartupInfo.cb:=SizeOf(StartupInfo);
    //TStartupInfo结构的大小为SizeOf(StartupInfo);
     StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
    //设置TStartupInfo的标志位,其各个选项的含义如下:
    (*
    dwFlagsThis is a bit field that determines whether certain STARTUPINFO members are used when the process creates a window. Any combination of the following values can be specified: Value Meaning
    STARTF_USESHOWWINDOW If this value is not specified, the wShowWindow member is ignored.
    STARTF_USEPOSITION If this value is not specified, the dwX and dwY members are ignored.
    STARTF_USESIZE If this value is not specified, the dwXSize and dwYSize members are ignored.
    STARTF_USECOUNTCHARS If this value is not specified, the dwXCountChars and dwYCountChars members are ignored.
    STARTF_USEFILLATTRIBUTE If this value is not specified, the dwFillAttribute member is ignored.
    STARTF_FORCEONFEEDBACK If this value is specified, the cursor is in feedback mode for two seconds after CreateProcess is called. If during those two seconds the process makes the first GUI call, the system gives five more seconds to the process. If during those five seconds the process shows a window, the system gives five more seconds to the process to finish drawing the window.
    The system turns the feedback cursor off after the first call to GetMessage, regardless of whether the process is drawing.
    For more information on feedback, see the following Res section.
    STARTF_FORCEOFFFEEDBACK If specified, the feedback cursor is forced off while the process is starting. The normal cursor is displayed. For more information on feedback, see the following Res section.
    STARTF_USESTDHANDLES If this value is specified, sets the standard input of the process, standard output, and standard error handles to the handles specified in the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure. The CreateProcess function's fInheritHandles parameter must be set to TRUE for this to work properly.
    If this value is not specified, the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure are ignored.*)
     StartupInfo.wShowWindow:=visiable;
    //这一句容易了,控制这个进程的窗口为可见的!
      

  3.   

    StartupInfo.wShowWindow:=visiable;
    //这一句容易了,控制这个进程的窗口为可见的!那么visiable的取值又有些什么规定呢?