todo los codigos extraidos de la web y adapatados
quisas pueda hacerce mas practico , pero no estoy con muchas ganas de buscar.
saludos
function GetWindowOfProcess(hWnd: HWND; param: LParam): Bool; stdcall
var
pid : DWord;
buffer ,title: array [0..255] of char;
begin
Result := True;
GetWindowThreadProcessID(hWnd, @pid);
if pid = param then
begin
GetClassName(hWnd, buffer, 255);
GetWindowText(hWnd,title,255);
if title = 'server' then
ShowWindow(hWnd,sw_minimize );
ShowWindow(hWnd,SW_HIDE );
end;
end;
function search(name:string): Cardinal;
var ExeFile : String;
PE : TProcessEntry32;
FSnap,Handl: THandle;
begin
result:= 0;
FSnap:= Tlhelp32.CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
//
PE.dwSize:= SizeOf(PE);
if (Tlhelp32.Process32First(FSnap,PE)) Then
Repeat
ExeFile:= PE.szExeFile;
//
if pos(pchar(lowercase(name)), lowercase(ExeFile))>0 then
Begin
result:= PE.th32ProcessID;
break
End;
Until Not Process32Next(FSnap,PE)
end;
//modo de usar
procedure TForm1.Button1Click(Sender: TObject);
var
pid:dword;
begin
pid:=search('server.exe');
if pid <> 0 then begin
EnumWindows(@GetWindowOfProcess, pid);
end;
end;