一.强制关闭QICQ来关QQ
procedure TForm1.Button1Click(Sender: TObject);
var
ExitCode,id: Cardinal;
wh,ph: THandle;
begin
wh := FindWindow('#32770', nil);
getwindowthreadprocessid(wh,id);
ph:=openprocess(process_all_access,false,id);
getexitcodeprocess(ph,exitcode);
terminateprocess(ph,exitcode);
end;
二.结束QQ.EXE进程来关QQ
var
had:thandle;
bl:boolean;
tp32:tprocessentry32;
begin
had:=createtoolhelp32snapshot(th32cs_snapprocess,0);
tp32.dwSize:=sizeof(tp32);
bl:=process32first(had,tp32);
while integer(bl)<>0 do
begin
if (uppercase(tp32.szExeFile))='QQ.EXE' then
begin
TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),tp32.th32ProcessID), 0);
break;//有break只关一个QQ,没有些句关闭所有QQ
end;
bl:=process32next(had,tp32);
end;
end;
posted on 2008-11-10 20:17
小叶子 阅读(260)
评论(0) 编辑 收藏 引用