FindWindow

{This code will launch and close Notepad from a checkbox.  FindWindow is the one to use in Win95 as hInstance will always be NIL in Win95.  This is so because each program gets its own space.}

procedure TForm1.CheckBox1Click(Sender: TObject);
var
  NotepadHandle: hWnd;
begin
  if checkbox1.checked then {start/stop checkbox}
    WinExec('c:\windows\notepad.exe c:\autoexec.bat', sw_ShowNormal)
  else begin
    NotepadHandle := FindWindow('Notepad', nil);
    SendMessage(NotepadHandle, wm_Close, 0, 0);
  end;
end;