判断某个进程是否存在
2010-02-05 23:58
260 查看
unit Unit1;
interface
uses
Windows,TLHelp32, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function FindProcess(AFileName:string):boolean;
var
hSnapshot:THandle;
lppe:TProcessEntry32;
Found:Boolean;
begin
Result:=False;
hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
lppe.dwSize:=SizeOf(TProcessEntry32);
Found:=Process32First(hSnapshot,lppe);
while Found do
begin
if((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName)) or (UpperCase(lppe.szExeFile )=UpperCase(AFileName))) then
begin
Result:=True;
end;
Found:=Process32Next(hSnapshot,lppe);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if FindProcess('Qq.exe')then
ShowMessage('进程存在')
else
ShowMessage('进程不存在');
end;
end.
interface
uses
Windows,TLHelp32, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function FindProcess(AFileName:string):boolean;
var
hSnapshot:THandle;
lppe:TProcessEntry32;
Found:Boolean;
begin
Result:=False;
hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
lppe.dwSize:=SizeOf(TProcessEntry32);
Found:=Process32First(hSnapshot,lppe);
while Found do
begin
if((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName)) or (UpperCase(lppe.szExeFile )=UpperCase(AFileName))) then
begin
Result:=True;
end;
Found:=Process32Next(hSnapshot,lppe);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if FindProcess('Qq.exe')then
ShowMessage('进程存在')
else
ShowMessage('进程不存在');
end;
end.
相关文章推荐
- 判断某个进程(例如.exe)是否存在,存在则关闭
- Linux Shell中判断进程是否存在的代码
- 判断指定的进程或程序是否存在方法小结(vc等)
- Visual Basic 中判断指定名称的进程是否存在
- java判断某个进程是否存在
- 批处理脚本:判断进程是否存在
- 判断进程是否存在,并杀死该进程
- python判断进程是否存在
- 根据pid判断某个进程是否存在
- shell脚本判断进程是否存在,并重新启动
- Python 判断一个进程是否存在
- VC判断指定进程是否存在IsExistProcess
- C#判断当前启动程序进程是否存在
- 一个判断进程是否存在的shell
- shell脚本判断Apache进程是否存在
- inno setup 安装前判断进程是否存在,以及停止相应进程
- 判断某进程是否存在
- windows判断进程是否存在脚本
- shell脚本循环判断进程是否存在
- 判断指定的进程或程序是否存在方法