function TaskRefresh:string;//显示所有正在运行的程序列表<br>var<br> ContinueLoop:BOOL;<br> FSnapshotHandle:THandle;<br> FProcessEntry32:TProcessEntry32;<br> PID : integer;//<br> s: string;//<br> PHandle : THandle;//<br>begin<br> FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br> FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);<br> ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32);<br> PID:=FProcessEntry32.th32ProcessID;//<br> while ContinueLoop do//<br> begin<br> s := ExtractFileName(FProcessEntry32.szExeFile);//<br> Result:=Result+(s)+#13+#10;<br> ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);<br> end;<br> CloseHandle(FSnapshotHandle);<br> PHandle:=OpenProcess(PROCESS_VM_WRITE,false,PID);<br> CloseHandle(PHandle);<br>end;