请问CreateProcess可以执行一个指定的EXE文件吗?(50分)

  • 主题发起人 主题发起人 aliangzl
  • 开始时间 开始时间
A

aliangzl

Unregistered / Unconfirmed
GUEST, unregistred user!
请问CreateProcess可以执行一个指定的EXE文件吗?<br>如果可以的话请问CreateProcess怎么用啊<br>他的参数该写什么?
 
可以,但一般用<br>ShellExecute(handle,nil,pchar('http://'+HOME_PAGE),nil,nil,sw_shownormal);<br>是户ShellExecute调用的就是CreateProcess,可查查ShellExecute的原马
 
运行一个程序并等待它终止 <br><br>function WinExecAndWait32(<br>&nbsp; FileName:String; Visibility :integer):integer;<br>var<br>&nbsp; zAppName:array[0..512] of char;<br>&nbsp; zCurDir:array[0..255] of char;<br>&nbsp; WorkDir:String;<br>&nbsp; StartupInfo:TStartupInfo;<br>&nbsp; ProcessInfo:TProcessInformation;<br>begin<br>&nbsp; StrPCopy(zAppName,FileName);<br>&nbsp; GetDir(0,WorkDir);<br>&nbsp; StrPCopy(zCurDir,WorkDir);<br>&nbsp; FillChar(StartupInfo,Sizeof(StartupInfo),#0);<br>&nbsp; StartupInfo.cb := Sizeof(StartupInfo);<br>&nbsp; StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br>&nbsp; StartupInfo.wShowWindow := Visibility;<br>&nbsp; if not CreateProcess(nil,zAppName,<br>&nbsp; &nbsp; { pointer to command line string }<br>&nbsp; &nbsp; nil, { pointer to process security attributes }<br>&nbsp; &nbsp; nil, { pointer to thread security attributes }<br>&nbsp; &nbsp; false, { handle inheritance flag }<br>&nbsp; &nbsp; CREATE_NEW_CONSOLE or { creation flags }<br>&nbsp; &nbsp; NORMAL_PRIORITY_CLASS,<br>&nbsp; &nbsp; nil, { pointer to new environment block }<br>&nbsp; &nbsp; nil, { pointer to current directory name }<br>&nbsp; &nbsp; StartupInfo, { pointer to STARTUPINFO }<br>&nbsp; &nbsp; ProcessInfo) then Result := -1 <br>&nbsp; &nbsp; { pointer to PROCESS_INF }<br>&nbsp; else begin<br>&nbsp; &nbsp; WaitforSingleObject(ProcessInfo.hProcess,INFINITE);<br>&nbsp; &nbsp; GetExitCodeProcess(ProcessInfo.hProcess,Result);<br>&nbsp; end;<br>end; <br><br>
 
后退
顶部