procedure mycreateprocess;<br>var<br> t:TStartupInfo;<br> s:TProcessInformation;<br> {$IFDEF Win32}<br> flag:boolean;<br> {$ENDIF}<br> {$IFDEF Win16}<br> flag1:integer;<br> {$ENDIF}<br>begin<br> t.cb:=Sizeof(STARTUPINFO);<br> //Specifies the size,in bytes,of the structure.<br><br> t.dwFlags:=STARTF_USESHOWWINDOW;<br> //If this value is not specified,the wShowWindow member is ignored.<br><br> t.wShowWindow:=SW_NORMAL;<br> //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.<br><br> t.cbReserved2:=0;<br> //Reserved;must be zero.<br><br> t.lpReserved:=nil;<br> //Reserved.Set this member to nil before passing the structure to CreateProcess.<br><br> t.lpReserved2:=nil;<br> //Reserved;must be nil.<br><br> t.lpDesktop:=nil;<br> //Windows NT only: Points to a zero-terminated string that specifies either the name of the desktop only or the name of both the window station and desktop for this process.<br> //A backslash in the string pointed to by lpDesktop indicates that the string includes both desktop and window station names.<br> //Otherwise, the lpDesktop string is interpreted as a desktop name.<br> //If lpDesktop is NULL, the new process inherits the window station and desktop of its parent process.<br><br> t.lpTitle:=nil;<br> //For console processes,<br> //this is the title displayed in the title bar if a new console window is created.<br> //If NULL, the name of the executable file is used as the window title instead.<br> //This parameter must be NULL for GUI or console processes that do not create a new console window.<br><br> {$IFDEF Win32}<br> if(classify='0')then<br> begin<br> flag:=CreateProcess(Pchar(commandline),nil,nil,nil,false,NORMAL_PRIORITY_CLASS,nil,nil,t,s);<br> end<br> else begin<br> flag:=CreateProcess(nil,Pchar(commandline),nil,nil,false,NORMAL_PRIORITY_CLASS,nil,nil,t,s);<br> end;<br> {$ENDIF}<br> <br> {$IFDEF Win16}<br> flag1:=WinExec(Pchar(commandline),SW_MAXIMIZE);<br> {$ENDIF}<br> <br> {$IFDEF Win32}<br> if not(flag)then<br> begin<br> savelog('CreateProcess error!');<br> end<br> else begin<br> savelog('CreateProcess success!');<br> end;<br> {$ENDIF}<br>end;<br><br><br><br>createprocess中的第一个参数可用来执行application,第二个参数可用来执行命令行(如net stop w3svc)<br>不建义使用winexec,它是16位的,尽因为向后兼容才保留!!