Показать сообщение отдельно
  #7  
Старый 03.09.2013, 05:36
lmikle lmikle вне форума
Модератор
 
Регистрация: 17.04.2008
Сообщения: 8,096
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
По умолчанию

Напиши одну процедуру, которая запускает инсталлятор, переданный как параметр. Соответственно, у тебя уберется куча одинакого кода, который вообще не отличается ничем, кроме указания пути к очередному инсталятору в начале блока. Примерно так:
Код:
procedure RunSetup(ExeсuteFile : String);
var
   SEInfo: TShellExecuteInfo;
   ExitCode: DWORD;
   ParamString, StartInString: string;
begin
  FillChar(SEInfo, SizeOf(SEInfo), 0); 
  SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
  with SEInfo do begin
     fMask := SEE_MASK_NOCLOSEPROCESS;
     Wnd := Application.Handle;
     lpFile := PChar(ExecuteFile) ;
     nShow := SW_SHOWNORMAL;
  end;
  if ShellExecuteEx(@SEInfo) then 
    begin
      repeat
         Application.ProcessMessages;
         GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
      until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
end; 

Тогда весь твой код, ну кроме этой процедуры, будет примерно такой:
Код:
if CheckBox8.Checked then RunSetup('Resourses\Programs\MSOFC07_scr\setup.exe');
if CheckBox9.Checked then RunSetup('Resourses\Programs\MSVIS07_scr\setup.exe');
if CheckBox2.Checked then RunSetup('Resourses\Programs\AIMP_scr\ampinst.exe');
if CheckBox3.Checked then RunSetup('Resourses\Programs\AdbRdr_scr\ARinst.exe');
if CheckBox4.Checked then RunSetup('Resourses\Programs\PirifCCl_scr\ccstpscrpt.exe');
if CheckBox12.Checked then RunSetup('Resourses\Programs\PirifDfrg_scr\dfinst.exe');
if CheckBox10.Checked then RunSetup('Resourses\Programs\PCS_scr\PCSINST.exe');
if CheckBox11.Checked then RunSetup('Resourses\Programs\SPLN_scr\spinst.exe');
if CheckBox13.Checked then RunSetup('Resourses\Programs\TTLCMD_scr\TCMINST.exe');
if CheckBox5.Checked then RunSetup('Resourses\Programs\KMP_scr\KMPInst.exe');
Ответить с цитированием