已知进程名如何获取此进程窗口句柄啊?
解决方案 »
- Delphi 调用SQLite 的OBJ
- 如何把与datetimepicker中日期里相同月份的数据检索出来
- 零件厂DELPHI上半年损失超过两兆美元
- cxgrid怎么实现记录序号显示,就象Execl表格最左边的记录序号显示列一样
- 请问:access支持的SQL中,求指数的函数是什么?
- SQL表达式问题
- 请教如何用delphi获取真实的下载地址,如迅雷的下载功能!
- 各位请帮忙.我的帖子是紧急!!!!!!(softkinx)我来不及了,帮忙啊大哥们
- 大侠! 怎么写DLL?
- z_jingxin(雪狼) 请进来
- 三层构架,COM+ ,一段时间不用,在一个非套接字上尝试了一个操作
- 批处理dbgrid多行选择数据出错。提示List index out of bounds (1)。
FSnapshotHandle, ProcessHndle: THandle;
FProcessEntry32: TProcessEntry32;
ContinueLoop: BOOL;
ProcessID : integer;
ItemName : String;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
Result := True;
Try
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
while integer(ContinueLoop) <>0 do
begin
ItemName := ExtractFileName(FProcessEntry32.szExeFile);
ProcessID := FProcessEntry32.th32ProcessID;
If UpperCase(ItemName) = 'QQ.EXE' Then//比較进程的名稱
Begin
ProcessHndle:=OpenProcess(PROCESS_ALL_ACCESS,BOOL(0),ProcessID); //进程的句柄
End; ContinueLoop :=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
Finally
CloseHandle(FSnapshotHandle);
End;
end;
var
lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
hh:hwnd;
s:string;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(Hand,lppe);
while found do
begin
s:=strpas(lppe.szExeFile);
if uppercase(s)='EXCEL.EXE' then
begin
hh:=openprocess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);
terminateprocess(hh,0); //中止进程
exit;
end;
found := Process32Next(Hand,lppe);
end;
end;