欢迎来到天天文库
浏览记录
ID:56826079
大小:44.50 KB
页数:2页
时间:2020-07-15
《Windows进程的创建与销毁.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Windows进程的创建与销毁内容及要求:①掌握Windows进程的创建和销毁API的调用方法;编程代码,在程序中创建和销毁一个Word进程;②能够挂起和激活被创建进程的主线程;③通过Windows进程管理器查看系统进程列表的变化。实验指导:①创建进程的APIBOOLCreateProcess(LPCTSTRlpApplicationName,LPTSTRlpCommandLine,LPSECURITY_ATTRIBUTESlpProcessAttributes,LPSECURITY_ATTRIBUTESlpThreadAttributes,BO
2、OLbInheritHandles,DWORDdwCreationFlags,LPVOIDlpEnvironment,LPCTSTRlpCurrentDirectory,LPSTARTUPINFOlpStartupInfo,LPPROCESS_INFORMATIONlpProcessInformation);例程:voidmain(VOID){STARTUPINFOsi;PROCESS_INFORMATIONpi;ZeroMemory(&si,sizeof(si));si.cb=sizeof(si);ZeroMemory(&pi,sizeof(p
3、i));//Startthechildprocess.if(!CreateProcess(NULL,//Nomodulename(usecommandline)."MyChildProcess",//Commandline.NULL,//Processhandlenotinheritable.NULL,//Threadhandlenotinheritable.FALSE,//SethandleinheritancetoFALSE.0,//Nocreationflags.NULL,//Useparent'senvironmentblock.NULL
4、,//Useparent'sstartingdirectory.&si,//PointertoSTARTUPINFOstructure.&pi)//PointertoPROCESS_INFORMATIONstructure.){ErrorExit("CreateProcessfailed.");}//Waituntilchildprocessexits.WaitForSingleObject(pi.hProcess,INFINITE);//Closeprocessandthreadhandles.CloseHandle(pi.hProcess);
5、CloseHandle(pi.hThread);}②销毁进程APIBOOLTerminateProcess(HANDLEhProcess,UINTuExitCode);③挂起进程的主线程APIDWORDSuspendThread(HANDLEhThread);④激活进程的主线程APIDWORDResumeThread(HANDLEhThread);⑤进程查看器
此文档下载收益归作者所有