如何在Inno Setup中捕获OleObject异常? [英] How to catch OleObject exception in Inno Setup?

查看:270
本文介绍了如何在Inno Setup中捕获OleObject异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试使用下一个修改的代码:

      WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpReq.Open('POST', '<your_web_server>', false);
      WinHttpReq.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      try
        WinHttpReq.Send('data');
      except
           bla:= 'e';
      finally
           bla := 'f';
      end;

但是仍未捕获到异常,下图显示了我对设置应用程序的迷恋:

Yet exception does not get catched and I get crush of my setup application with next image:

如何在Inno Setup中处理OleObject异常?

How to handle OleObject exception in Inno Setup?

推荐答案

您的代码不完整,但是try..except块捕获了所有异常,包括OLE对象抛出的异常.但是,您的屏幕快照显示了行号,引发异常的位置,因此您正在运行调试器.

Your code is incomplete, but try..except block catches all the exceptions, including those thrown by OLE objects. However, your screenshot shows the line number, where the exception was thrown, and so you were running debugger.

并且调试器将显示所有异常消息,无论它们是否位于try..except块中,除非您在Inno Setup IDE设置中取消选中异常暂停" 选项,

And debugger shows all exception messages regardless they are in a try..except block, unless you uncheck "Pause on exceptions" option in Inno Setup IDE settings:

默认情况下启用此选项(我建议保留此选项),这意味着所有异常都将报告为异常消息,这可能会误导您.如果您在运行安装程序时未连接调试器,则不会看到该异常消息.

By default is this option enabled (which I would recommend to keep), which means that all exceptions are reported as exception messages and that's what might have mislead you. If you were running your setup without debugger attached, you wouldn't see that exception message.

这篇关于如何在Inno Setup中捕获OleObject异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆