procedure TForm1.Button1Click(Sender: TObject);
var
Processesid:array[0..1023] of DWORD;
hMod:array[0..1023] of HMODULE;
FileName:array[0..MAX_PATH] of Char;
cbNeeded,size1WORD;
i:Integer;
hProcess:THandle;
begin
//获取进程信息的id
if not EnumProcesses(@Processesid[0],sizeof(Processesid),cbNeeded) then Exit;
size1:=cbNeeded div sizeof(DWORD);
for i:=0 to size1-1 do
begin
hProcess:=OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,False,Processesid);
if hProcess<>0 then
begin
//煤举进程信息
if EnumProcessModules(hProcess,@hMod[0],SizeOf(hMod),cbNeeded) then
begin
//获取进程信息名称
GetModuleFileNameEx(hProcess,hMod[0],@FileName[0],sizeof(FileName));
//如果进程信息名称于规定名称相同,干掉该程序
if UpperCase(ExtractFileName(FileName))='WINWORD.EXE' then
begin
TerminateProcess(hProcess,0);
Exit;
end;
end;
end;
//释放据宾
CloseHandle(hProcess);
end;
可以使Timer进行检测,在此处添加预关闭的对象:UpperCase(ExtractFileName(FileName))='WINWORD.EXE'
给分吧,呵呵![]