На примере запуска блокнота, нужно лишь на форму кинуть таймер и подключить его обработчик
Код:
uses Tlhelp32;
const s = 'Notepad';
function IsRunning(sName :string): boolean;
var
han: THandle;
ProcStruct: PROCESSENTRY32; // from "tlhelp32" in uses clause
sID: string;
begin
Result:= false;
// Get a snapshot of the system
han:= CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
if han = 0 then exit;
// Loop thru the processes until we find it or hit the end
ProcStruct.dwSize:= SizeOf(PROCESSENTRY32);
if Process32First(han, ProcStruct) then
begin
repeat
sID := ExtractFileName(ProcStruct.szExeFile);
// Check only against the portion of the name supplied, ignoring case
if UpperCase(Copy(sId, 1, Length(sName))) = UpperCase(sName) then
begin
// Report we found it
Result:= true;
Break;
end;
until not Process32Next(han, ProcStruct);
end;
// clean-up
CloseHandle(han);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not IsRunning(s) then WinExec(PAnsiChar(s), SW_SHOW);
end;
drkb