Inno setup Inno安装程序语法错误2

Inno setup Inno安装程序语法错误2,inno-setup,pascal,Inno Setup,Pascal,我再一次与Pascal语法作斗争 我只是不明白应该在哪里使用开始和结束 我目前的方法是这样的,但Inno安装程序告诉我,“if IsServiceRunning('oscmaintenanceservice')=true then”行中应该有一个分号 有人能解释一下吗 谢谢大家! begin if (CurStep=ssInstall) then MsgBox('ssInstall.', mbInformation, MB_OK); if IsS

我再一次与Pascal语法作斗争

我只是不明白应该在哪里使用开始和结束

我目前的方法是这样的,但Inno安装程序告诉我,“if IsServiceRunning('oscmaintenanceservice')=true then”行中应该有一个分号

有人能解释一下吗

谢谢大家!

begin
   if (CurStep=ssInstall) then
           MsgBox('ssInstall.', mbInformation, MB_OK);
           if IsServiceInstalled('oscmaintenanceservice') = true then
               MsgBox('ssInstall: Service is installed.', mbInformation, MB_OK);
               if IsServiceRunning('oscmaintenanceservice') = true then
                           MsgBox('ssInstall: Service is running.', mbInformation, MB_OK);
                       if not StopService('oscmaintenanceservice') = true then
                               MsgBox('ssInstall: Couldnt stop service.', mbInformation, MB_OK);
                       else
                               MsgBox('ssInstall: Service was stopped.', mbInformation, MB_OK);
                           if not RemoveService('oscmaintenanceservice') = true then
                                   MsgBox('ssInstall: Couldnt remove service.', mbInformation, MB_OK);
                           else
                                   MsgBox('ssInstall: Service was removed', mbInformation, MB_OK);
               else
                       MsgBox('ssInstall: Service not running.', mbInformation, MB_OK);
               end;
           else
                   MsgBox('ssInstall: Service not installed.', mbInformation, MB_OK);
   if (CurStep = ssPostInstall) then
       DeleteFile(ExpandConstant('{localappdata}\OnScreenCommunicator\mutex.dat'));
       PinAppTo(ExpandConstant('{app}\OSC.exe'),  pdStartMenu);
       if (IsHigherThanWindowsXP()) then
       begin
           PinAppTo(ExpandConstant('{app}\OSC.exe'), pdTaskbar);
       end;
       if not InstallService(ExpandConstant('{app}\maintenanceservice.exe'),'oscmaintenanceservice','oscmaintenanceservice','desc', SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START) = true then
       begin
           MsgBox('ssPostInstall: Couldnt install service.', mbInformation, MB_OK);
       end;
       if not StartService(ExpandConstant('{app}\maintenanceservice.exe')) then
       begin
           MsgBox('ssPostInstall: Couldnt start service.', mbInformation, MB_OK);
       end

这是代码的一个版本,具有最小的编号
开始
结束

过程CurStepChanged(CurStep:TSetupStep);
开始
如果CurStep=ssInstall,则
开始
MsgBox('ssInstall',MB信息,MB_OK);
如果已安装IsService(“oscmaintenanceservice”),则
开始
MsgBox('ssInstall:服务已安装'),MB信息,MB_OK);
如果是服务运行('oscmaintenanceservice'),则
开始
MsgBox('ssInstall:服务正在运行'),mbInformation,MB_OK);
如果不是停止服务(“oscmaintenanceservice”),则
MsgBox('ssInstall:Couldnt stop service',MB信息,MB_OK)
其他的
MsgBox('ssInstall:服务已停止'),MB信息,MB_OK);
如果未移除服务(“oscmaintenanceservice”),则
MsgBox('ssInstall:couldn remove service',MB信息,MB_OK)
其他的
MsgBox('ssInstall:服务已删除',MB信息,MB_OK);
结束
else MsgBox('ssInstall:Service not running',MB信息,MB_OK)
结束
else MsgBox('ssInstall:Service not installed'),MB信息,MB_OK)
结束;
如果CurStep=ssPostInstall,则
开始
DeleteFile(ExpandConstant({localappdata}\onScreenCommucator\mutex.dat');
PinAppTo(ExpandConstant({app}\OSC.exe'),pdStartMenu);
如果是Windows XP(),则
PinAppTo(ExpandConstant({app}\OSC.exe'),pdTaskbar);
如果未安装服务(ExpandConstant({app}\maintenanceservice.exe')、'oscmaintenanceservice'、'oscmaintenanceservice'、'desc',SERVICE\u WIN32\u OWN\u PROCESS,SERVICE\u AUTO\u START),则
开始
MsgBox('ssPostInstall:无法安装服务',MB信息,MB_OK);
如果没有启动服务(ExpandConstant({app}\maintenanceservice.exe'),则
MsgBox('ssPostInstall:无法启动服务',MB信息,MB_OK)
结束;
结束;
结束;
为了进行比较,下面是代码的等效版本,其中包含所有可选/冗余的
开始
结束
。也许这会帮助你理解

过程CurStepChanged(CurStep:TSetupStep);
开始
如果CurStep=ssInstall,则
开始
MsgBox('ssInstall',MB信息,MB_OK);
如果已安装IsService(“oscmaintenanceservice”),则
开始
MsgBox('ssInstall:服务已安装'),MB信息,MB_OK);
如果是服务运行('oscmaintenanceservice'),则
开始
MsgBox('ssInstall:服务正在运行'),mbInformation,MB_OK);
如果不是停止服务(“oscmaintenanceservice”),则
开始
MsgBox('ssInstall:Couldnt stop service',MB信息,MB_OK);
结束
其他的
开始
MsgBox('ssInstall:服务已停止'),MB信息,MB_OK);
结束;
如果未移除服务(“oscmaintenanceservice”),则
开始
MsgBox('ssInstall:Couldnt remove service',mbinfo,MB_OK);
结束
其他的
开始
MsgBox('ssInstall:服务已删除',MB信息,MB_OK);
结束;
结束
其他的
开始
MsgBox('ssInstall:Service not running',mbInformation,MB_OK);
结束;
结束
其他的
开始
MsgBox('ssInstall:Service not installed',MB信息,MB_OK);
结束;
结束;
如果CurStep=ssPostInstall,则
开始
DeleteFile(ExpandConstant({localappdata}\onScreenCommucator\mutex.dat');
PinAppTo(ExpandConstant({app}\OSC.exe'),pdStartMenu);
如果是Windows XP(),则
开始
PinAppTo(ExpandConstant({app}\OSC.exe'),pdTaskbar);
结束;
如果未安装服务(ExpandConstant({app}\maintenanceservice.exe')、'oscmaintenanceservice'、'oscmaintenanceservice'、'desc',SERVICE\u WIN32\u OWN\u PROCESS,SERVICE\u AUTO\u START),则
开始
MsgBox('ssPostInstall:无法安装服务',MB信息,MB_OK);
如果没有启动服务(ExpandConstant({app}\maintenanceservice.exe'),则
开始
MsgBox('ssPostInstall:无法启动服务'),MB信息,MB_OK);
结束;
结束;
结束;
结束;

一旦你了解了这一点,请接受副本,或者完全删除你的问题。

我在@MartinPrikryl链接的帖子中写了一篇关于使用begin..end in Pascal和Inno设置的非常全面的指南。我希望有一个在线转换器可用。:-)@MartinPrikryl我确实看到了你的教程,但无论如何,有些地方还是出了问题。您是否愿意看一下我当前的代码?您问题中的代码在
if(CurStep=ssInstall)then
之后缺少
begin
。它在
if(CurStep=ssPostInstall)之后的代码块周围缺少
begin
end
。Pascal不是一种复杂的语言(这就是为什么他们使用它来教授编程)。我写了一篇关于使用
begin..end
的教程已经存在,我们已经向您展示了它的位置。如果你不想费心通读它来解决你的问题,并且你期望我们提供的不仅仅是一个清晰、简洁的教程,那么你期望我们牵着你的手,照顾你的孩子,而这不是本网站的目的。我们分享知识,你有责任将我们分享的知识应用到你的特殊情况中。