inno-setupinno-tools-downloader

InnoTools Downloader not working with Inno 5.5


On the recommendation of several posts here on SO, I've been working with the InnoTools Downloader to try to install a 3rd party dependency for our app during the Install script in Inno setup.

Unfortunately the InnoTools Downloader hasn't been updated in a few years, and is starting to look like it's incompatible with the current Inno Tools setup (5.5.2 (u) on my machine at present). The PChar parameters in ITD have been replaced by PAnsiChar parameters, and when I try to run the various ITD_xxx procedures it gives me varying degrees of fail:

Has anyone gotten ITP to run with newer Inno (post-5.3.0) unicode versions? Or should I look around for another solution?

EDIT Just to clarify things a bit, I have tried going into the it_download.iss file and replacing all instances of PChar with PAnsiChar. This got me past the compile errors when I first tried to integrate ITD with my setup script.

Here is a sample section of the Inno script:

[Code]
procedure InitializeWizard();
begin
  ITD_Init; // initialize the InnoTools Downloader
  // install 3rd party tool (ex. Git) from the internet.
  if ITD_DownloadFile('http://git-scm.com/download/win',expandconstant('{tmp}\GitInstaller.exe'))=ITDERR_SUCCESS then begin
     MsgBox(expandconstant('{tmp}\GitInstaller.exe'), mbInformation, MB_OK);
     Exec(ExpandConstant('{tmp}\GitInstaller.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, tmpResult);
  end
end;

When this is run, it will bring up a dialog stating where it "downloaded" and stored the file -- on my machine it's in a subdirectory of c:\Users\\AppData\Local\Temp. This file is 6KB, as opposed to the file downloaded from http://git-scm.com/download/win, which is currently 15,221KB.

The ITP_DownloadAfter method gives a similar result.


Solution

  • Except replacing all PChar type occurrences with PAnsiChar you will need to replace all occurrences of string type with AnsiString in the it_download.iss file. The next problem is the URL you're trying to get. The size of a file differs from expectation, because you are downloading a HTML document instead of the binary file on which that site redirects. So, if you have your ITD ready for Unicode, change the URL in your script to a direct binary URL. Note, that I didn't used HTTPS because ITD doesn't currently support SSL. A code proof may look like this:

    [Code]
    const
      GitSetupURL = 'http://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe';
    
    procedure InitializeWizard;
    var
      Name: string;
      Size: Integer;
    begin
      Name := ExpandConstant('{tmp}\GitInstaller.exe');
    
      ITD_Init;  
      if ITD_DownloadFile(GitSetupURL, Name) = ITDERR_SUCCESS then
      begin
        if FileSize(Name, Size) then
          MsgBox(Name + #13#10 + 'Size: ' + IntToStr(Size) + ' B',
            mbInformation, MB_OK)
        else
          MsgBox('FileSize function failed!', mbError, MB_OK);
      end;
    end;