Jump to content

question on TFileStream (Inno Setup)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
mainguy

mainguy

    Newbie

  • Members
  • Pip
  • 5 posts
Hello,

I'm using Inno Setup for the first time and just a beginner in Pascal.

My code:
XMLHTTP := CreateOleObject('MSXML2.ServerXMLHTTP');
XMLHTTP.Open('GET', myUrl, False);
XMLHTTP.Send();
...
MyFileStream := TFileStream.Create(Path + MyFilename, fmCreate or fmOpenWrite);
But,I don't know how to use MyFileStream to write XMLHTTP.ResponseBody or XMLHTTP.ResponseStream.

Could you please help me?

Thanks,
Maggie

Edited by Jaan, 18 September 2009 - 04:06 AM.
Please use code tags when you are posting your codes !


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Is this Object Pascal, Delphi, something else?

You haven't really offered much information. Is your goal to read from the FileStream and push the results to the XMLHTTP? Also, if XMLHTTP is getting data from a URL, the responsebody would be from the data the URL sent. Also, responsebody is read-only, so you cannot copy the contents of filestream into the responsebody.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
mainguy

mainguy

    Newbie

  • Members
  • Pip
  • 5 posts
I want to write the content of XMLHTTP.ResponseStream (or ResponseBody -- don't know what to use) into a file. There is a Write() method for TFileStream:

function Write(Buffer: String; Count: Longint): Longint;

but I don't know how to get the String and the Count from.

Thanks,
Maggie

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I think Count is optional. It would probably be something like Write(XMLHTTP.REsponseBody)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
mainguy

mainguy

    Newbie

  • Members
  • Pip
  • 5 posts
No, it will give a compiler error: "Invalid number of parameters"

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Based on this: Delphi: Reading and writing a file to and from a string
Write(XMLHTTP.REsponseBody,Length(XMLHTTP.REsponseBody))
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
mainguy

mainguy

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks. The compiler doesn't complain any more when I use Length(...).

However, the file I want to download is an exe file. It's a 15MB file.

But

MyFileStream.Write(XMLHTTP.ResponseBody, Length(XMLHTTP.ResponseBody));

the file written down by TFileStream only has around 7MB. And when I run the downloaded exe file, it says "Programs too big to fix in memory".

Then if I do:

MyFileStream.Write(XMLHTTP.ResponseStream, Length(XMLHTTP.ResponseStream));

Then I would receive a runtime error:

Exception: Invalid variant type conversion.

Any advice on how to download this adobe air file using Pascal?

Thanks,
Maggie

Edited by Jaan, 19 September 2009 - 08:55 AM.
Please use code tags when you are posting your codes !


#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What exactly are you trying to do? It sounds like you shouldn't be using the XMLHTTP object at all.

Try looking at this: Programmatically Download Web Documents from the Internet using Delphi
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
The Cat

The Cat

    Newbie

  • Members
  • Pip
  • 2 posts
I have to agree - that XML object is for parsing XML structures, not downloading EXEs from websites.
Either download that EXE yourself and include it with the INNO installer, or try something like this free utility: HTTPCOPY (you'll have to Google it)
Which you could include temporarily within your installer, i.e. install it to the TEMP folder, then run it, like this:


[Files]

Source: "HTTPCOPY.EXE"; DestDir : "{tmp}"; Flags: ignoreversion deleteafterinstall


[Run]

Filename: "{tmp}\HTTPCOPY.EXE"; Parameters: "h t t   p : //blah.blah.com/file.exe";


Having said that, I've never used that command line utility HTTPCOPY but it looks as though it'll do what you want!

#10
mainguy

mainguy

    Newbie

  • Members
  • Pip
  • 5 posts
We can't include the exe with our installation because we have to sign a distribution agreement with adobe unless this is the only solution.

Thanks for all your inputs. I'm still figuring out what to do next.

- Maggie

#11
The Cat

The Cat

    Newbie

  • Members
  • Pip
  • 2 posts
I've just tried that utility and it does work. Not sure if there is any size restriction though. Good luck!