uses tlhelp32; procedure checkpro; var ippe:tprocessentry32; sshandle:thandle; found:boolean; begin sshandle:=createtoolhelp32snapshot(TH32CS_SNAPPROCESS,0); found:=process32first(sshandle,ippe); while found do begin if ansicomparetext(extractfilename(ippe.szExeFile),‘进程名字')=0 then begin showmessage('该进程存在!'); break; end; found:=process32next(sshandle,ippe); end; end;
Var hMutex : hWnd; Ret : integer; begin Application.Initialize; hMutex:=CreateMutex(NIL,False,'sysfilm'); Ret:=GetLastError; IF Ret<>ERROR_ALREADY_EXISTS then BEGIN showmessage('没运行'); end else showmessage('已经运行了'); end;
shellApi 也不顶事呀.
procedure checkpro;
var
ippe:tprocessentry32;
sshandle:thandle;
found:boolean;
begin
sshandle:=createtoolhelp32snapshot(TH32CS_SNAPPROCESS,0);
found:=process32first(sshandle,ippe);
while found do
begin
if ansicomparetext(extractfilename(ippe.szExeFile),‘进程名字')=0 then
begin
showmessage('该进程存在!');
break;
end;
found:=process32next(sshandle,ippe);
end;
end;
hMutex : hWnd;
Ret : integer;
begin
Application.Initialize;
hMutex:=CreateMutex(NIL,False,'sysfilm');
Ret:=GetLastError;
IF Ret<>ERROR_ALREADY_EXISTS then
BEGIN
showmessage('没运行');
end
else
showmessage('已经运行了');
end;
楼上的说的是,可是我搜过了,就搜到一楼给的那个帖了,调试时,说那些API的类型没定义,加了
shellApi 也不顶事呀.