在自开发的安装包内如何关闭当前tomcat的线程
imiss2008
|
1#
imiss2008 发表于 2007-07-14 22:40
在自开发的安装包内如何关闭当前tomcat的线程
/*下面是我的installshield 开发包程序,其中有线程的API函数控制,但是执行到
:STOP[????????????????????????]标志时无法继续打开线程指针 跪求请哪位高手帮解决一下使得 nProcess = Process32First(hSnapProcess,pe);能成功打开线程! */ #include "ifx.h " //*****定义进程 " PROCESSENTRY32 " 结构类型 typedef PROCESSENTRY32 begin number dwSize; number cntUsage; number th32ProcessID;//进程句柄 number th32DefaultHeapID; number th32ModuleID; number cntThreads; number th32ParentProcessID; long pcPriClassBase; number dwFlags; char szExeFile (MAX_PATH); end; #define MAX_MODULE_NAME32 255 #define MAX_MODULE_NAME32plus 256 #define TH32CS_SNAPPROCESS 2 // #define TH32CS_SNAPPROCESS 0x00000002 #define TH32CS_SNAPMODULE 8 //---------------------定义动态库-------------------------// prototype INT kernel32.CreateToolhelp32Snapshot(long,long); prototype INT kernel32.Process32First(long,POINTER); prototype INT kernel32.Process32Next(long,POINTER); prototype INT kernel32.CloseHandle (long); //-------------------------安装main()-------------------------\\ function OnFirstUIBefore() number nResult,nSetupType; string szTitle, szMsg; string szLicenseFile, szQuestion; string szName, szCompany, szSerial; string szTargetPath; string szDir; string szComponents, szTargetdir; number nLevel,hSnapProcess,nProcess; LIST listStartCopy; number nvType,listID,nvSize,nRootID; string nregfiles,svKey,svName,tomcatClassPath,tomcatHome,nSearchFile,tempVar; int i,l,hasData; PROCESSENTRY32 POINTER pe; /*---------------------------------------- PROCESSENTRY32 :进程信息结构类型 hSnapProcess :进程表开启句柄 nProcess :线程句柄 nSearchFile :进程文件名称 tomcatClassPath:Tomcate 类路经 tomcatHome :Tomcate安装路经 -----------------------------------------*/ begin nSetupType = TYPICAL; nregfiles= " "; tomcatClassPath= " "; tomcatHome= " "; nProcess=-1; nSearchFile= "tomcat.exe "; hasData=0; tempVar= " "; //**************************定义线线程函数***************************** //1:定义PROCESSENTRY32结构 //2:引入API函数CreateToolhelp32Snapshot(), Process32First(), kernel32.Process32Next() //3:用UseDLL(ApiFile)加载动态库 API //4:调用API //5:关闭线程句柄 //-------------------------------------------------------------------- nResult=UseDLL( "kernel32 "); if(nResult <0) then MessageBox( "Sorry,出现莫名错误! ",WARNING);abort; endif; hSnapProcess=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); //TH32CS_SNAPPROCESS if(hSnapProcess <=0) then //不能大开线程 MessageBox( "Sorry,出现莫名错误! ",WARNING);abort; endif; nProcess = Process32First(hSnapProcess,pe); //-------------执行到此出现nProcess =0 而 hSnapProcess> 124 //:STOP[????????????????????????] NumToStr(nregfiles,nProcess); MessageBox(nregfiles,WARNING); //nProcess = Process32Next(hSnapProcess,pe); //如果在最后的结束过程nProcess> =0 得重新启动进程 // if (nProcess> 0) then //获取Windows 开始进程 // while (nProcess!=0) // tempVar= pe-> szExeFile; //if (nSearchFile=pe-> szExeFile)hasData=1; // nProcess = Process32Next(hSnapProcess,pe) ; //endwhile; //endif; //...... |