Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

question on TFileStream (Inno Setup)

pascal stream

  • Please log in to reply
10 replies to this topic

#1 mainguy

mainguy

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 18 September 2009 - 04:05 AM

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 !

  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 18 September 2009 - 07:36 AM

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.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 mainguy

mainguy

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 18 September 2009 - 08:20 AM

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
  • 0

#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 18 September 2009 - 10:20 AM

I think Count is optional. It would probably be something like Write(XMLHTTP.REsponseBody)
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 mainguy

mainguy

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 18 September 2009 - 12:07 PM

No, it will give a compiler error: "Invalid number of parameters"
  • 0

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 18 September 2009 - 03:56 PM

Based on this: Delphi: Reading and writing a file to and from a string
Write(XMLHTTP.REsponseBody,Length(XMLHTTP.REsponseBody))
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 mainguy

mainguy

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 18 September 2009 - 04:22 PM

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 !

  • 0

#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 19 September 2009 - 04:09 PM

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
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 The Cat

The Cat

    CC Lurker

  • New Member
  • Pip
  • 6 posts
  • Programming Language:JavaScript, VBScript
  • Learning:Objective-C, JavaScript, Visual Basic .NET

Posted 05 October 2009 - 05:42 AM

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!
  • 0

#10 mainguy

mainguy

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 05 October 2009 - 08:14 AM

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
  • 0

#11 The Cat

The Cat

    CC Lurker

  • New Member
  • Pip
  • 6 posts
  • Programming Language:JavaScript, VBScript
  • Learning:Objective-C, JavaScript, Visual Basic .NET

Posted 05 October 2009 - 08:21 AM

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





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download