procedure TFormulario.FormCreate(Sender: TObject);
function SacaExe(MangoW:HWND):string;
var
Datos :TProcessEntry32;
hID :DWord;
Snap : Integer;
begin
GetWindowThreadProcessId(MangoW,@hID);
Snap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
Datos.dwSize:=SizeOf(Datos);
if(Process32First(Snap,Datos))then
begin
repeat
if Datos.th32ProcessID=hID then
begin
Result:=StrPas(Datos.szExeFile);
Break;
end;
until not(Process32Next(Snap,Datos));
end;
finally
Windows.CloseHandle(Snap);
end;
end;
function ObtieneVentanas(Mango: HWND;
Nada: Pointer): Boolean; stdcall;
var
sTemp:string;
begin
Result := True;
sTemp:=SacaExe(Mango);
If sTemp = 'Nombre_del_ejecutable.exe' then bExistePrograma := True;
end;
begin
bExistePrograma := False;
EnumWindows( @ObtieneVentanas, 0 );
end;