Tu mismo te respondes, si lo que quieres es obtener el segundo proceso, una solución sería ignorar de alguna manera al primero que consiga.
Bueno, como te veo demasiado perdido respecto al tema, y parece ser que tienes miedo a investigar un poco, me he tomado la molestia de reformarte la función para que te permita obtener el PID que deseas:
Código Delphi
[-]Function GetProcessID(Const ExeFileName: string; var ProcessId: integer;
Const ProcessNo :Integer = 1): boolean;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
Temp: Integer;
begin
result := false;
temp:=1;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while integer(ContinueLoop) <> 0 do
begin
if (StrIComp(PChar(ExtractFileName(FProcessEntry32.szExeFile)), PChar(ExeFileName)) = 0)
or (StrIComp(FProcessEntry32.szExeFile, PChar(ExeFileName)) = 0) then
begin
If Temp = ProcessNo then
begin
ProcessId:= FProcessEntry32.th32ProcessID;
result := true;
break;
end else inc(Temp);
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
Un ejemplo de como usarlo:
Código Delphi
[-]procedure TForm1.Button1Click(Sender: TObject);
var PID: Integer;
begin
PID:= 0;
If GetProcessID('svchost.exe', PID, 3) then
ShowMessage(IntToStr(PID));
end;
En el tercer parámetro de GetProcessID indicas el número del proceso que quieres si tienen un mismo nombre de ejecutable, de forma que por defecto será 1; el 2 sería el segundo proceso que encontrase con un nombre igual, el 3, 4, 5... .
Investigar no hace daño.
Por cierto, tu post ha mejorado pero solo un poco
tienes que practicar más.
Un saludo.
Edito: Feliz año a todos
.