public_fun.pas
资源名称:进程监视.rar [点击查看]
上传用户:mrkingwuhu
上传日期:2007-05-27
资源大小:185k
文件大小:1k
源码类别:
控制台编程
开发平台:
Delphi
- unit public_fun;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- ImgList, Menus, ShellApi, ExtCtrls, StdCtrls, Dialogs, TLHelp32, strutils, Buttons;
- const
- mymsg=wm_user+1;// WM_USER = $0400;
- iid=100;
- //About proceeding define
- type
- TProcessInfo = Record
- ExeFile : String;
- ProcessID : DWORD;
- end;
- pProcessInfo = ^TProcessInfo;
- function detecthread(str_thread:string):string;
- implementation
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- function detecthread(str_thread:string):string;
- var p : pProcessInfo;
- ContinueLoop:BOOL;
- i:integer;
- var
- FSnapshotHandle:THandle;
- FProcessEntry32:TProcessEntry32;
- begin
- i:=0;
- FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
- FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
- ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32);
- while integer(ContinueLoop)<>0 do
- begin
- New(p);
- p.ExeFile := FProcessEntry32.szExeFile;
- p.ProcessID := FProcessEntry32.th32ProcessID;
- if LowerCase(p.ExeFile)=LowerCase(str_thread) then i:=i+1;//proceeding is exist-->i=i+1
- ContinueLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);
- end;
- if i<1 then//proceeding is not exist
- begin
- result:=('notexist');
- end
- else
- begin
- result:=('exist');
- end;
- end;
- end.