代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
C
】
获得进程各项信息
作者:
/ 发布于
2011/1/3
/
561
说明:这个类可以获得任何进程的线程数.cpu使用率.进程名字(非进程路径).只要你设置了正确的PID.通过SetPid即可使用.
<div> <div class="container"> <div class="line number1 index0 alt2">"cpp preprocessor">#pragma once </div> <div class="line number2 index1 alt1">"cpp spaces"></div> <div class="line number3 index2 alt2">"cpp preprocessor">#define MAX_SIZE 255 </div> <div class="line number4 index3 alt1">"cpp spaces"></div> <div class="line number5 index4 alt2">"cpp keyword bold">typedef "cpp keyword bold">struct "cpp plain">_THREAD_INFO </div> <div class="line number6 index5 alt1">"cpp plain">{ </div> <div class="line number7 index6 alt2">"cpp spaces">"cpp plain">LARGE_INTEGER CreateTime; </div> <div class="line number8 index7 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwUnknown1; </div> <div class="line number9 index8 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwStartAddress; </div> <div class="line number10 index9 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">StartEIP; </div> <div class="line number11 index10 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwOwnerPID; </div> <div class="line number12 index11 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwThreadId; </div> <div class="line number13 index12 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwCurrentPriority; </div> <div class="line number14 index13 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwBasePriority; </div> <div class="line number15 index14 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwContextSwitches; </div> <div class="line number16 index15 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">Unknown; </div> <div class="line number17 index16 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">WaitReason; </div> <div class="line number18 index17 alt1">"cpp spaces"></div> <div class="line number19 index18 alt2">"cpp plain">}THREADINFO, *PTHREADINFO; </div> <div class="line number20 index19 alt1">"cpp spaces"></div> <div class="line number21 index20 alt2">"cpp keyword bold">typedef "cpp keyword bold">struct "cpp plain">_UNICODE_STRING </div> <div class="line number22 index21 alt1">"cpp plain">{ </div> <div class="line number23 index22 alt2">"cpp spaces">"cpp color1 bold">USHORT "cpp plain">Length; </div> <div class="line number24 index23 alt1">"cpp spaces">"cpp color1 bold">USHORT "cpp plain">MaxLength; </div> <div class="line number25 index24 alt2">"cpp spaces">"cpp color1 bold">PWSTR "cpp plain">Buffer; </div> <div class="line number26 index25 alt1">"cpp plain">} UNICODE_STRING; </div> <div class="line number27 index26 alt2">"cpp spaces"></div> <div class="line number28 index27 alt1">"cpp keyword bold">typedef "cpp keyword bold">struct "cpp plain">_PROCESS_INFO </div> <div class="line number29 index28 alt2">"cpp plain">{ </div> <div class="line number30 index29 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwOffset; </div> <div class="line number31 index30 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwThreadsCount; </div> <div class="line number32 index31 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwUnused1[6]; </div> <div class="line number33 index32 alt2">"cpp spaces">"cpp plain">LARGE_INTEGER CreateTime; </div> <div class="line number34 index33 alt1">"cpp spaces">"cpp plain">LARGE_INTEGER UserTime; </div> <div class="line number35 index34 alt2">"cpp spaces">"cpp plain">LARGE_INTEGER KernelTime; </div> <div class="line number36 index35 alt1">"cpp spaces">"cpp plain">UNICODE_STRING ProcessName; </div> <div class="line number37 index36 alt2">"cpp spaces"></div> <div class="line number38 index37 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwBasePriority; </div> <div class="line number39 index38 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwProcessID; </div> <div class="line number40 index39 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwParentProcessId; </div> <div class="line number41 index40 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwHandleCount; </div> <div class="line number42 index41 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwUnused3[2]; </div> <div class="line number43 index42 alt2">"cpp spaces"></div> <div class="line number44 index43 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwVirtualBytesPeak; </div> <div class="line number45 index44 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwVirtualBytes; </div> <div class="line number46 index45 alt1">"cpp spaces">"cpp color1 bold">ULONG "cpp plain">dwPageFaults; </div> <div class="line number47 index46 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwWorkingSetPeak; </div> <div class="line number48 index47 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwWorkingSet; </div> <div class="line number49 index48 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwQuotaPeakPagedPoolUsage; </div> <div class="line number50 index49 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwQuotaPagedPoolUsage; </div> <div class="line number51 index50 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwQuotaPeakNonPagedPoolUsage; </div> <div class="line number52 index51 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwQuotaNonPagedPoolUsage; </div> <div class="line number53 index52 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwPageFileUsage; </div> <div class="line number54 index53 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwPageFileUsagePeak; </div> <div class="line number55 index54 alt2">"cpp spaces"></div> <div class="line number56 index55 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dCommitCharge; </div> <div class="line number57 index56 alt2">"cpp spaces">"cpp plain">THREADINFO ThreadSysInfo[1]; </div> <div class="line number58 index57 alt1">"cpp spaces"></div> <div class="line number59 index58 alt2">"cpp plain">} PROCESSINFO, *PPROCESSINFO; </div> <div class="line number60 index59 alt1">"cpp spaces"></div> <div class="line number61 index60 alt2">"cpp spaces"></div> <div class="line number62 index61 alt1">"cpp keyword bold">class "cpp plain">CServerInfo </div> <div class="line number63 index62 alt2">"cpp plain">{ </div> <div class="line number64 index63 alt1">"cpp keyword bold">public"cpp plain">: </div> <div class="line number65 index64 alt2">"cpp spaces">"cpp plain">CServerInfo("cpp keyword bold">void"cpp plain">); </div> <div class="line number66 index65 alt1">"cpp spaces">"cpp plain">~CServerInfo("cpp keyword bold">void"cpp plain">); </div> <div class="line number67 index66 alt2">"cpp spaces"></div> <div class="line number68 index67 alt1">"cpp spaces">"cpp color1 bold">int "cpp plain">GetProcessUsage(); </div> <div class="line number69 index68 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">GetThreadCount(); </div> <div class="line number70 index69 alt1">"cpp spaces">"cpp color1 bold">char"cpp plain">* GetProcessName(); </div> <div class="line number71 index70 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">GetPid(); </div> <div class="line number72 index71 alt1">"cpp spaces">"cpp keyword bold">void "cpp plain">SetPid("cpp color1 bold">int "cpp plain">Pid); </div> <div class="line number73 index72 alt2">"cpp spaces"></div> <div class="line number74 index73 alt1">"cpp keyword bold">private"cpp plain">: </div> <div class="line number75 index74 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">m_nPid; </div> <div class="line number76 index75 alt1">"cpp spaces">"cpp color1 bold">char "cpp plain">m_szProcessName[MAX_SIZE]; </div> <div class="line number77 index76 alt2">"cpp plain">}; </div> <div class="line number78 index77 alt1">"cpp spaces"></div> <div class="line number79 index78 alt2">"cpp spaces"></div> <div class="line number80 index79 alt1">"cpp comments">//CPP </div> <div class="line number81 index80 alt2">"cpp preprocessor">#include "StdAfx.h" </div> <div class="line number82 index81 alt1">"cpp preprocessor">#include <process.h> </div> <div class="line number83 index82 alt2">"cpp preprocessor">#include <TLHELP32.H> </div> <div class="line number84 index83 alt1">"cpp preprocessor">#include "ServerInfo.h" </div> <div class="line number85 index84 alt2">"cpp spaces"></div> <div class="line number86 index85 alt1">"cpp spaces"></div> <div class="line number87 index86 alt2">"cpp plain">CServerInfo::CServerInfo("cpp keyword bold">void"cpp plain">) </div> <div class="line number88 index87 alt1">"cpp plain">{ </div> <div class="line number89 index88 alt2">"cpp spaces">"cpp plain">m_nPid=::getpid(); </div> <div class="line number90 index89 alt1">"cpp spaces"></div> <div class="line number91 index90 alt2">"cpp spaces">"cpp color1 bold">HANDLE "cpp plain">h = OpenProcess(NULL,0,getpid()); </div> <div class="line number92 index91 alt1">"cpp spaces">"cpp color1 bold">char "cpp plain">buf[256]; </div> <div class="line number93 index92 alt2">"cpp spaces">"cpp functions bold">memset"cpp plain">(buf,0,256); </div> <div class="line number94 index93 alt1">"cpp spaces">"cpp functions bold">memset"cpp plain">(m_szProcessName,0,255); </div> <div class="line number95 index94 alt2">"cpp spaces">"cpp plain">GetModuleFileName(("cpp color1 bold">HINSTANCE"cpp plain">)h,buf,256); </div> <div class="line number96 index95 alt1">"cpp spaces"></div> <div class="line number97 index96 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">pos=0; </div> <div class="line number98 index97 alt1">"cpp spaces">"cpp keyword bold">for"cpp plain">("cpp color1 bold">int "cpp plain">i=0;i<"cpp functions bold">strlen"cpp plain">(buf)-1;i++) </div> <div class="line number99 index98 alt2">"cpp spaces">"cpp plain">{ </div> <div class="line number100 index99 alt1">"cpp spaces">"cpp keyword bold">if"cpp plain">(buf[i]=="cpp string">'\\'"cpp plain">) </div> <div class="line number101 index100 alt2">"cpp spaces">"cpp plain">pos=i; </div> <div class="line number102 index101 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number103 index102 alt2">"cpp spaces"></div> <div class="line number104 index103 alt1">"cpp spaces">"cpp keyword bold">for"cpp plain">("cpp color1 bold">int "cpp plain">k=pos;k<"cpp functions bold">strlen"cpp plain">(buf);k++) </div> <div class="line number105 index104 alt2">"cpp spaces">"cpp plain">{ </div> <div class="line number106 index105 alt1">"cpp spaces">"cpp plain">m_szProcessName[k-pos]=buf[k+1]; </div> <div class="line number107 index106 alt2">"cpp spaces">"cpp plain">} </div> <div class="line number108 index107 alt1">"cpp plain">} </div> <div class="line number109 index108 alt2">"cpp spaces"></div> <div class="line number110 index109 alt1">"cpp plain">CServerInfo::~CServerInfo("cpp keyword bold">void"cpp plain">) </div> <div class="line number111 index110 alt2">"cpp plain">{ </div> <div class="line number112 index111 alt1">"cpp plain">} </div> <div class="line number113 index112 alt2">"cpp spaces"></div> <div class="line number114 index113 alt1">"cpp keyword bold">void "cpp plain">CServerInfo::SetPid("cpp color1 bold">int "cpp plain">Pid) </div> <div class="line number115 index114 alt2">"cpp plain">{ </div> <div class="line number116 index115 alt1">"cpp spaces">"cpp plain">m_nPid=Pid; </div> <div class="line number117 index116 alt2">"cpp plain">} </div> <div class="line number118 index117 alt1">"cpp spaces"></div> <div class="line number119 index118 alt2">"cpp color1 bold">int "cpp plain">CServerInfo::GetProcessUsage() </div> <div class="line number120 index119 alt1">"cpp plain">{ </div> <div class="line number121 index120 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">cpuusage=0; </div> <div class="line number122 index121 alt1">"cpp spaces">"cpp color1 bold">PVOID "cpp plain">pProcInfo = NULL; </div> <div class="line number123 index122 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwInfoSize = 0x20000; </div> <div class="line number124 index123 alt1">"cpp spaces">"cpp plain">PPROCESSINFO pProcessInfo; </div> <div class="line number125 index124 alt2">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwWorkingSet; </div> <div class="line number126 index125 alt1">"cpp spaces">"cpp color1 bold">long "cpp plain">( __stdcall *NtQuerySystemInformation )( "cpp color1 bold">DWORD"cpp plain">, "cpp color1 bold">PVOID"cpp plain">, "cpp color1 bold">DWORD"cpp plain">, "cpp color1 bold">DWORD "cpp plain">); </div> <div class="line number127 index126 alt2">"cpp spaces"></div> <div class="line number128 index127 alt1">"cpp spaces"></div> <div class="line number129 index128 alt2">"cpp spaces">"cpp keyword bold">static "cpp color1 bold">__int64 "cpp plain">LastTotalProcessCPUUsage = 0; </div> <div class="line number130 index129 alt1">"cpp spaces">"cpp keyword bold">static "cpp color1 bold">__int64 "cpp plain">LastCurrentProcessCPUUsage = 0; </div> <div class="line number131 index130 alt2">"cpp spaces"></div> <div class="line number132 index131 alt1">"cpp spaces">"cpp color1 bold">int "cpp plain">CurrentDelta; </div> <div class="line number133 index132 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">TotalDelta; </div> <div class="line number134 index133 alt1">"cpp spaces"></div> <div class="line number135 index134 alt2">"cpp spaces">"cpp color1 bold">__int64 "cpp plain">TotalProcessCPUUsage = 0; </div> <div class="line number136 index135 alt1">"cpp spaces">"cpp color1 bold">__int64 "cpp plain">CurrentProcessCPUUsage = 0; </div> <div class="line number137 index136 alt2">"cpp spaces"></div> <div class="line number138 index137 alt1">"cpp spaces">"cpp comments">///////////////////////////////// </div> <div class="line number139 index138 alt2">"cpp spaces"></div> <div class="line number140 index139 alt1">"cpp spaces">"cpp plain">pProcInfo = ("cpp color1 bold">PVOID"cpp plain">)("cpp keyword bold">new "cpp color1 bold">char"cpp plain">[dwInfoSize]); </div> <div class="line number141 index140 alt2">"cpp spaces"></div> <div class="line number142 index141 alt1">"cpp spaces">"cpp plain">NtQuerySystemInformation = ("cpp color1 bold">long"cpp plain">(__stdcall*)("cpp color1 bold">DWORD"cpp plain">,"cpp color1 bold">PVOID"cpp plain">,"cpp color1 bold">DWORD"cpp plain">,"cpp color1 bold">DWORD"cpp plain">)) </div> <div class="line number143 index142 alt2">"cpp spaces">"cpp plain">GetProcAddress( GetModuleHandle( "cpp string">"ntdll.dll" "cpp plain">),"cpp string">"NtQuerySystemInformation" "cpp plain">); </div> <div class="line number144 index143 alt1">"cpp spaces"></div> <div class="line number145 index144 alt2">"cpp spaces">"cpp plain">NtQuerySystemInformation(5,pProcInfo,dwInfoSize,0); </div> <div class="line number146 index145 alt1">"cpp spaces"></div> <div class="line number147 index146 alt2">"cpp spaces">"cpp plain">pProcessInfo = (PPROCESSINFO)pProcInfo; </div> <div class="line number148 index147 alt1">"cpp spaces"></div> <div class="line number149 index148 alt2">"cpp spaces">"cpp keyword bold">do</div> <div class="line number150 index149 alt1">"cpp spaces">"cpp plain">{ </div> <div class="line number151 index150 alt2">"cpp spaces">"cpp plain">TotalProcessCPUUsage += ("cpp color1 bold">__int64"cpp plain">)pProcessInfo->KernelTime.QuadPart + ("cpp color1 bold">__int64"cpp plain">)pProcessInfo->UserTime.QuadPart; </div> <div class="line number152 index151 alt1">"cpp spaces"></div> <div class="line number153 index152 alt2">"cpp spaces">"cpp keyword bold">if"cpp plain">(pProcessInfo->dwProcessID == m_nPid) </div> <div class="line number154 index153 alt1">"cpp spaces">"cpp plain">{ </div> <div class="line number155 index154 alt2">"cpp spaces">"cpp plain">dwWorkingSet = pProcessInfo->dwWorkingSet; </div> <div class="line number156 index155 alt1">"cpp spaces">"cpp plain">CurrentProcessCPUUsage += ("cpp color1 bold">__int64"cpp plain">)pProcessInfo->KernelTime.QuadPart + ("cpp color1 bold">__int64"cpp plain">)pProcessInfo->UserTime.QuadPart; </div> <div class="line number157 index156 alt2">"cpp spaces">"cpp plain">} </div> <div class="line number158 index157 alt1">"cpp spaces"></div> <div class="line number159 index158 alt2">"cpp spaces">"cpp comments">///////// </div> <div class="line number160 index159 alt1">"cpp spaces">"cpp keyword bold">if"cpp plain">(pProcessInfo->dwOffset == 0) </div> <div class="line number161 index160 alt2">"cpp spaces">"cpp plain">{ </div> <div class="line number162 index161 alt1">"cpp spaces">"cpp keyword bold">break"cpp plain">; </div> <div class="line number163 index162 alt2">"cpp spaces">"cpp plain">} </div> <div class="line number164 index163 alt1">"cpp spaces"></div> <div class="line number165 index164 alt2">"cpp spaces">"cpp plain">pProcessInfo = (PPROCESSINFO)(("cpp color1 bold">char"cpp plain">*)pProcessInfo + pProcessInfo->dwOffset); </div> <div class="line number166 index165 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number167 index166 alt2">"cpp spaces">"cpp keyword bold">while"cpp plain">("cpp keyword bold">true"cpp plain">); </div> <div class="line number168 index167 alt1">"cpp spaces"></div> <div class="line number169 index168 alt2">"cpp spaces">"cpp plain">TotalDelta = TotalProcessCPUUsage - LastTotalProcessCPUUsage; </div> <div class="line number170 index169 alt1">"cpp spaces">"cpp plain">CurrentDelta = CurrentProcessCPUUsage - LastCurrentProcessCPUUsage; </div> <div class="line number171 index170 alt2">"cpp spaces">"cpp keyword bold">if"cpp plain">(TotalDelta != 0) </div> <div class="line number172 index171 alt1">"cpp spaces">"cpp plain">cpuusage = 100 * CurrentDelta / TotalDelta; </div> <div class="line number173 index172 alt2">"cpp spaces"></div> <div class="line number174 index173 alt1">"cpp spaces">"cpp plain">LastTotalProcessCPUUsage = TotalProcessCPUUsage; </div> <div class="line number175 index174 alt2">"cpp spaces">"cpp plain">LastCurrentProcessCPUUsage = CurrentProcessCPUUsage; </div> <div class="line number176 index175 alt1">"cpp spaces"></div> <div class="line number177 index176 alt2">"cpp spaces">"cpp keyword bold">delete"cpp plain">[] pProcInfo; </div> <div class="line number178 index177 alt1">"cpp spaces">"cpp keyword bold">if"cpp plain">(cpuusage<0||cpuusage>100) </div> <div class="line number179 index178 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">-1; </div> <div class="line number180 index179 alt1">"cpp spaces">"cpp keyword bold">return "cpp plain">cpuusage; </div> <div class="line number181 index180 alt2">"cpp plain">} </div> <div class="line number182 index181 alt1">"cpp spaces"></div> <div class="line number183 index182 alt2">"cpp color1 bold">int "cpp plain">CServerInfo::GetPid() </div> <div class="line number184 index183 alt1">"cpp plain">{ </div> <div class="line number185 index184 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">m_nPid; </div> <div class="line number186 index185 alt1">"cpp plain">} </div> <div class="line number187 index186 alt2">"cpp spaces"></div> <div class="line number188 index187 alt1">"cpp color1 bold">char"cpp plain">* CServerInfo::GetProcessName() </div> <div class="line number189 index188 alt2">"cpp plain">{ </div> <div class="line number190 index189 alt1">"cpp spaces">"cpp keyword bold">return "cpp plain">m_szProcessName; </div> <div class="line number191 index190 alt2">"cpp plain">} </div> <div class="line number192 index191 alt1">"cpp spaces"></div> <div class="line number193 index192 alt2">"cpp color1 bold">int "cpp plain">CServerInfo::GetThreadCount() </div> <div class="line number194 index193 alt1">"cpp plain">{ </div> <div class="line number195 index194 alt2">"cpp spaces">"cpp color1 bold">HANDLE "cpp plain">hProcessSnap; </div> <div class="line number196 index195 alt1">"cpp spaces">"cpp color1 bold">HANDLE "cpp plain">hProcess; </div> <div class="line number197 index196 alt2">"cpp spaces">"cpp plain">PROCESSENTRY32 pe32; </div> <div class="line number198 index197 alt1">"cpp spaces">"cpp color1 bold">DWORD "cpp plain">dwPriorityClass; </div> <div class="line number199 index198 alt2">"cpp spaces"></div> <div class="line number200 index199 alt1">"cpp spaces">"cpp plain">hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); </div> <div class="line number201 index200 alt2">"cpp spaces">"cpp keyword bold">if "cpp plain">(hProcessSnap == INVALID_HANDLE_VALUE) </div> <div class="line number202 index201 alt1">"cpp spaces">"cpp plain">{ </div> <div class="line number203 index202 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">-1; </div> <div class="line number204 index203 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number205 index204 alt2">"cpp spaces"></div> <div class="line number206 index205 alt1">"cpp spaces">"cpp plain">pe32.dwSize = "cpp keyword bold">sizeof"cpp plain">(PROCESSENTRY32); </div> <div class="line number207 index206 alt2">"cpp spaces"></div> <div class="line number208 index207 alt1">"cpp spaces">"cpp keyword bold">if "cpp plain">(!Process32First(hProcessSnap, &pe32)) </div> <div class="line number209 index208 alt2">"cpp spaces">"cpp plain">{ </div> <div class="line number210 index209 alt1">"cpp spaces">"cpp plain">CloseHandle(hProcessSnap); </div> <div class="line number211 index210 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">-1; </div> <div class="line number212 index211 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number213 index212 alt2">"cpp spaces"></div> <div class="line number214 index213 alt1">"cpp spaces"></div> <div class="line number215 index214 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">res; </div> <div class="line number216 index215 alt1">"cpp spaces">"cpp color1 bold">int "cpp plain">Try=0; </div> <div class="line number217 index216 alt2">"cpp spaces">"cpp color1 bold">int "cpp plain">trycount=300; </div> <div class="line number218 index217 alt1">"cpp spaces">"cpp keyword bold">while"cpp plain">(Try<trycount) </div> <div class="line number219 index218 alt2">"cpp spaces">"cpp plain">{ </div> <div class="line number220 index219 alt1">"cpp spaces">"cpp plain">Process32Next(hProcessSnap,&pe32); </div> <div class="line number221 index220 alt2">"cpp spaces">"cpp keyword bold">if"cpp plain">(pe32.th32ProcessID == m_nPid) </div> <div class="line number222 index221 alt1">"cpp spaces">"cpp plain">{ </div> <div class="line number223 index222 alt2">"cpp spaces">"cpp plain">res=("cpp color1 bold">int"cpp plain">)pe32.cntThreads; </div> <div class="line number224 index223 alt1">"cpp spaces">"cpp plain">CloseHandle(hProcessSnap); </div> <div class="line number225 index224 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">res; </div> <div class="line number226 index225 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number227 index226 alt2">"cpp spaces">"cpp plain">Try++; </div> <div class="line number228 index227 alt1">"cpp spaces">"cpp plain">} </div> <div class="line number229 index228 alt2">"cpp spaces">"cpp keyword bold">return "cpp plain">0; </div> <div class="line number230 index229 alt1">"cpp plain">}</div> </div> </div>
试试其它关键字
同语言下
.
获取手机通讯录 iOS去除数字以外的所有字符
.
异步加载音乐等资源
.
交通罚单管理系统
.
freemark实现,简单的替换
.
计算斐波那契数列
.
base64解码 包括解码长度
.
图像显示
.
冒泡排序
.
输入十进制数,输出指定进制
.
链式栈
可能有用的
.
获取手机通讯录 iOS去除数字以外的所有字符
.
异步加载音乐等资源
.
交通罚单管理系统
.
freemark实现,简单的替换
.
计算斐波那契数列
.
base64解码 包括解码长度
.
图像显示
.
冒泡排序
.
输入十进制数,输出指定进制
.
链式栈
贡献的其它代码
Label
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3