Inno-Setup 缺少分号

Inno-Setup Semicolon missing

我有以下函数会导致 "Semicolon missing." 错误”,但我不明白为什么。

感谢您的帮助!

 function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
   if not IsServiceRunning('oscmaintenanceserver') then
       begin
           MsgBox('Service not running. Exit.', mbInformation, MB_OK);
           exit;
       end
   end
   if not StopService('oscmaintenanceserver') then
       begin
           MsgBox('Service couldnt be stopped.', mbInformation, MB_OK);
           exit;
       end
   end
   if not RemoveService('oscmaintenanceserver') then
       begin
           MsgBox('Couldnt remove service.', mbInformation, MB_OK);
           exit;
       end
   end   
   begin
       MsgBox('All went fine :-).', mbInformation, MB_OK);
       exit;
   end
end;

您在每个 if 分支中都有一个额外的 end。此外,在标记语句结束时,end 后面需要一个分号。

 function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
   if not IsServiceRunning('oscmaintenanceserver') then
       begin
           MsgBox('Service not running. Exit.', mbInformation, MB_OK);
           exit;
       end;
   if not StopService('oscmaintenanceserver') then
   ...