2

I've got a problem when people who tries to install my file has connection problems. It appears a message and you cannot retry nor wait until you solve the problem. It just has an accept button and the setup closes. So I would like to have a message saying "No connection, check it." or something similar and allow you to fix the problem and continue. The error is given by this line: WinHttpRequest.Send; Thanks in advanced.

  function DownloadFile(const AURL: string; var AResponse: string): Boolean;
  var
    WinHttpRequest: Variant;
  begin
    Result := True;
    try
      WinHttpRequest := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpRequest.Open('GET', AURL, False);
      WinHttpRequest.Send;
      AResponse := WinHttpRequest.ResponseText;
    except
      Result := False;
      AResponse := GetExceptionMessage;
    end;
  end;
DeXon
  • 419
  • 4
  • 12
  • Information about whether the remote resource has been downloaded or not is returned by the `Result` of the function. There is no message saying anything. It's something outside of this function that does it. – TLama Apr 27 '14 at 19:41
  • I've tested it when having no connection in the code you previously provide me (http://stackoverflow.com/questions/22269116/inno-setup-check-for-new-updates) and it says there is a problem in WinHttpRequest.Send; – DeXon Apr 27 '14 at 19:49
  • You can see an exception message when you run your script in debugger, but not when you run the setup separately. That `try..expcept` block just protects against showing any error messages. – TLama Apr 27 '14 at 19:56
  • So, where should I put that part of the code in mine to get the message I want? I've tried several things but no luck. I always have an error message in the line I mentioned before. – DeXon Apr 27 '14 at 20:43
  • Yes, but that error message you see because you're running the script in debugger. If you would execute that setup separately (e.g. from Windows Explorer), no error message would be shown. But back to your question, so you want to ask the user to retry checking of the new version when downloading of the version file fails for some reason ? If so, wouldn't that be misleading ? I mean, you start the setup and without doing anything you'll get a message dialog saying something like "Checking of an update failed. Retry ?". – TLama Apr 27 '14 at 21:02
  • I've moved the verification to when you click the button next, so now when somebody runs the setup, clicks next and doesn't have connection or is under a proxy, the error message appears. So what I want to do is to have a message saying they don't have connection and it is needed to follow. – DeXon Apr 28 '14 at 11:30
  • I don't manage to solved this error. http://s2.subirimagenes.com/imagen/previo/thump_8895091sin-ttulo.png And the error always appear in those lines. http://pastebin.com/M1YAbpEN – DeXon Apr 30 '14 at 14:52
  • For the third time, that error message is shown by debugger (that play button, or F9 key in other words) :-) If you run the setup separately e.g. from Windows Explorer, that dialog won't appear because the exception is handled by the `try..except` block. It's debugger's business to show you any exception that occurs, even those that are handled by `try..except` block; that's the nature of debugging. I think you can turn this off through menu "Tools / Options" check box "Pause on exceptions", but do not do that since it is a useful feature. – TLama Apr 30 '14 at 15:03
  • That error only occurs when there is **no connection**. When there is connection, it works perfectly. Thanks. – DeXon Apr 30 '14 at 15:48
  • I precisely understand when the exception is raised, but **that exception is handled**, so no message box will be shown to the user. That you see the message box means that you are running the script in debugger. Your users will get the setup.exe binary which when they run won't show that message box. You need to distinguish between terms exception and error message box. That exception will still be raised if any problem occurs, but because it's catched by the `try..except` block, no error message box will be shown to the user. – TLama Apr 30 '14 at 15:59
  • I understand that but even when I'm not in debugger, since I saved the setup as if it were for the user (in binary), I still get that message when I don't have connection to the net. Here I give you an example https://www.mediafire.com/?7917296a19v7x3o Try it with connection and with no connection. As soon as you click next when no connection it appears and you'll understand my problem. Thanks so much and sorry for the inconveniences. – DeXon Apr 30 '14 at 16:13
  • No problem :) Now looking at your pastebin code, didn't you forget to uncomment that `try..except` block ? That block must be there to catch the exceptions. If catching of exceptions wouldn't work, it would be a production stopper for Inno Setup of your version... It must work. – TLama Apr 30 '14 at 16:20
  • The code of what I sent is this one http://pastebin.com/SNU6ArHu As you can see none of them is commented – DeXon Apr 30 '14 at 16:38
  • 1
    Well, I think I see the problem now. You're not checking the result of my `DownloadFile` function and as the result in its `AResponse` parameter you're getting the exception message which is then compared to the version string which results to showing a confirmation dialog with that exception message. Something [`like this`](http://pastebin.com/JN7p3KjF) might be better I think ;-) – TLama Apr 30 '14 at 16:57
  • Thanks a bunch! I was getting mad at this, and I guess you too xD As a final request, would it be possible to get a info message? – DeXon Apr 30 '14 at 17:20
  • Err, about what ? Where ? Why ? :) – TLama Apr 30 '14 at 17:22
  • Because it is a online setup, all components user will install are downloaded from the net in the moment they click next, so if they don't have internet connection, it won't work. That's why I need to check internet connection and then a info message letting the user know they don't have it, and they'll be able to fix their connection before going on. – DeXon Apr 30 '14 at 17:27
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/51769/discussion-between-tlama-and-dexon) – TLama Apr 30 '14 at 17:29

0 Answers0