avatar

进程&模块相关函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function FindProcess(AFileName: string): boolean;
var
 hSnapshot: THandle;
 lppe: TProcessEntry32;
 Found: Boolean;
 KillHandle: THandle;
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;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function FindModule(AFileName: string): boolean;
var
 hSnapshot: THandle;
 lppe: tagModuleentry32;
 Found: Boolean;
begin
 Result :=False;
 hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPModule, 0);
 lppe.dwSize := SizeOf(TMODULEENTRY32);
 Found := Module32First(hSnapshot, lppe);
 while Found do
 begin
   if ((UpperCase(ExtractFileName(lppe.szModule))=UpperCase(AFileName)) or (UpperCase(lppe.szModule )=UpperCase(AFileName))) then
   begin
     Result :=True;
   end;
   Found :=  Module32Next(hSnapshot, lppe);
 end;
end;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
procedure EndProcess(AFileName: string);
const
 PROCESS_TERMINATE = $0001;
var
 ContinueLoop: BOOL;
 FSnapShotHandle: THandle;
 FProcessEntry32: TProcessEntry32;
begin
 FSnapShotHandle := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0);
 FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
 ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
 while integer(ContinueLoop) <> 0 do
 begin
   if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))=UpperCase(AFileName)) or (UpperCase(FProcessEntry32.szExeFile )=UpperCase(AFileName))) then
   TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),FProcessEntry32.th32ProcessID), 0);
   ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
 end;
end;
Comments ( 0 ) Trackbacks ( 0 ) Leave a Reply
  1. No comments yet.

    目前尚无任何评论.

    コメントはまだありません。

  2.                    
  1. No trackbacks yet.

    目前尚无任何 trackbacks 和 pingbacks.

    トラックバックはまだありません。

  • ☆*:.。. o(≧▽≦)o .。.:*☆
  • _(:з」∠)_
  • ♪(´ε` )
  • ψ(`∇´)ψ
  • (-_-#)
  • (=´∀`)人(´∀`=)
  • \(//∇//)\
  • ♪(*^^)o∀*∀o(^^*)♪
  • (((o(*゚▽゚*)o)))
  • (´・_・`)
  • σ(^_^;)
  • ( *`ω´)
  • (ノ`Д´)ノ
  • (( _ _ ))..zzzZZ
  • ( ̄▽ ̄)
  • ヽ(`Д´#)ノ
  • ((((;゚Д゚)))))))
  • (>_<)
  • (T_T)
  • ( T_T)\(^-^ )
  • ε=ε=ε=ε=ε=ε=┌(; ̄◇ ̄)┘