关于 CreateProcess()和ExitProcess()?(200分)

  • 主题发起人 主题发起人 yp_shen
  • 开始时间 开始时间
Y

yp_shen

Unregistered / Unconfirmed
GUEST, unregistred user!
请教CreateProcess函数和ExitProcess函数的详细用法,和例程!
 
 你可以参考win32api,上面又很详细的讲解!
 
函数原型是:<br>BOOL CreateProcess(<br>&nbsp; LPCTSTR lpApplicationName, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // name of executable module<br>&nbsp; LPTSTR lpCommandLine, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// command line string<br>&nbsp; LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD<br>&nbsp; LPSECURITY_ATTRIBUTES lpThreadAttributes, &nbsp;// SD<br>&nbsp; BOOL bInheritHandles, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// handle inheritance option<br>&nbsp; DWORD dwCreationFlags, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // creation flags<br>&nbsp; LPVOID lpEnvironment, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// new environment block<br>&nbsp; LPCTSTR lpCurrentDirectory, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// current directory name<br>&nbsp; LPSTARTUPINFO lpStartupInfo, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // startup information<br>&nbsp; LPPROCESS_INFORMATION lpProcessInformation // process information<br>);<br>第一个参数是可执行文件的全路径。第二个参数是其所带的命令行,<br>第三和第四个参数是分别是进程和线程的安全属性,如为null , 则继承父亲。<br>第五个表示是否继承父亲打开的句斌,第六个是一些创建标志具体可察看msdn<br>其余的可察看msdn。<br><br>给出一个示例:<br>STARTUPINFO si;<br>PROCESS_INFORMATION pi;<br><br>ZeroMemory( &amp;si, sizeof(si) );<br>si.cb = sizeof(si);<br><br>CreateProcess( para, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi ) <br>只要把para改成你的可执行文件名字!!<br><br>成功是返回true, 失败返回false<br><br>ExitProcess(int ExitCode);<br>推出本进程!!!<br><br>不知你满意吗???给分吧!!!!!
 
请详解:<br>&nbsp; LPSTARTUPINFO lpStartupInfo, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // startup information<br>&nbsp; LPPROCESS_INFORMATION lpProcessInformation // process information<br>
 
你太笨,可以参考 Platform SDK.
 
&gt;你太笨<br>这话有点……那个……
 
有任何问题看MSDN
 
不是太笨,是太懒:-)
 
http://knigh.126.com/<br>&nbsp;API函数 --- 进程和线程函数 --- CreateProcess<br>看看有用吗?<br>有用就的给分啊!
 
StrayBear 大虾说得很好了,只是要注意结构数据的大小,不要引起内存泄漏。
 
yp_shen:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br>
 
接受答案了.
 
后退
顶部