function FindProcess(ExeNames:
string): integer;
stdcall;
function DeleteExe(s:
string):
string;
var i, j: integer;
begin
setlength(result,length(s));
result := '
';
j := 0;
for i := 1
to length(s)
do
begin
if (copy(s,i,6) = ('
.EXE'#13#10))
then
j := 4;
if (j > 0)
then
dec(j)
else result := result+s[i];
end;
end;
var
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
ContinueLoop: BOOL;
exesearch,exeprocess:
string;
i: integer;
begin
result := 0;
exesearch := deleteexe(uppercase(#13#10+exenames+#13#10));
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
while ContinueLoop
do
begin
exeprocess := uppercase(uallUtil.extractfilename(FProcessEntry32.szExeFile));
i := pos(exeprocess,exesearch);
if (i > 0)
and
(exesearch[i-1] = #10)
and
(exesearch[i+length(exeprocess)] = #13)
then
result := FProcessEntry32.th32ProcessID;
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;