首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PrepareToInstall定时

PrepareToInstall定时
EN

Stack Overflow用户
提问于 2016-05-24 11:59:09
回答 1查看 58关注 0票数 1

我使用PrepareToInstall事件来停止和删除服务。这很好,没有抛出错误。

然而,有时似乎出现了时间问题,因为有时InnoSetup告诉我,“涛动维护服务”仍然在运行,并询问是否应该关闭它。

我认为如果API从函数返回以关闭和删除服务,那么应用程序就应该已经消失了。

有没有人认为我有任何错误,或者有什么建议给我?

谢谢!

代码语言:javascript
复制
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin

    //MsgBox('ssInstall.', mbInformation, MB_OK);

   if IsServiceInstalled('oscmaintenanceservice') then
   BEGIN
       //MsgBox('ssInstall: Service is installed.', mbInformation, MB_OK);

       if IsServiceRunning('oscmaintenanceservice') then
           BEGIN
               //MsgBox('ssInstall: Service is running.', mbInformation, MB_OK);

               if not StopService('oscmaintenanceservice') then
               BEGIN
                   MsgBox('ssInstall: Couldnt stop service.', mbInformation, MB_OK);
               END
           else
           BEGIN
               //MsgBox('ssInstall: Service was stopped.', mbInformation, MB_OK);
           END;
       END
           else
           BEGIN
               MsgBox('ssInstall: Service not running.', mbInformation, MB_OK);
           END;
       if not RemoveService('oscmaintenanceservice') then
           BEGIN
               MsgBox('ssInstall: Couldnt remove service.', mbInformation, MB_OK);
           END
           else
           BEGIN
               //MsgBox('ssInstall: Service was removed', mbInformation, MB_OK);
           END;
   END
   else
   BEGIN
       MsgBox('ssInstall: Service not installed.', mbInformation, MB_OK);
   END;
END;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-24 17:49:48

看来Windows需要一点时间来识别已删除的服务。

在PrepareToInstall中的停止和删除函数之后,我增加了睡眠(1000),从那时起,它工作得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37412927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档