Board index » delphi » Binary Files...

Binary Files...

How can I read an ordinary binary file so I can make a manual installation
program?  The files DO NOT contain records they are machine language
binaries.  Do I have to read the Hex values and then rewrite them or what?
Any help is greatly appreciated!
                                              thank You,
                                                Joshua Davis

--

                       The South Will Rise Again.....
                 |---------------------------------------|
                 |\     \                         /     /|
                 |  \  *  \                     /  *  /  |
                 |    \     \                 /     /    |
                 |      \  *  \             /  *  /      |
                 |        \     \         /     /        |
                 |          \  *  \     /  *  /          |
                 |            \     \ /     /            |
                 |              \         /              |
                 |              /    *    \              |
   Free By       |            /     / \     \            |...Southern By
     Birth...    |          /  *  /     \  *  \          |    The Grace Of
                 |        /     /         \     \        |      GOD!!!
                 |      /  *  /             \  *  \      |
                 |    /     /                 \     \    |
                 |  /  *  /                     \  *  \  |
                 |/     /                         \     \|
                 |---------------------------------------|
                (I'm not racist, just a PROUD SOUTHERNER!!)

 

Re:Binary Files...


Quote
Joshua Davis wrote:

> How can I read an ordinary binary file so I can make a manual installation
> program?  The files DO NOT contain records they are machine language
> binaries.  Do I have to read the Hex values and then rewrite them or what?

Look up BlockWrite/BlockRead.
And, man, you've got a large ugly sig.....

M.

--
Martin Larsson, author of several unknown utilities for DOS and Windows.
mailto:martin.lars...@delfi-data.msmail.telemax.no
http://www.delfi.infonet.no
X.400:G=martin;S=larsson;O=delfi-data;P=msmail;A=telemax;C=no

Re:Binary Files...


In article <slrn44nl5on.j5n.dav...@mcnet.marietta.edu>,
   dav...@mcnet.marietta.edu (Joshua Davis) wrote:

Quote
>How can I read an ordinary binary file so I can make a manual installation
>program?  The files DO NOT contain records they are machine language
>binaries.  Do I have to read the Hex values and then rewrite them or what?
>Any help is greatly appreciated!

Look in the documentation under File and BlockRead, BlockWrite. They will
allow you to copy anything.

Re:Binary Files...


On 24 Apr 1996 11:45:13 GMT, mcha...@vcn.com (Mike Chapin) wrote:

Quote
>In article <slrn44nl5on.j5n.dav...@mcnet.marietta.edu>,
>   dav...@mcnet.marietta.edu (Joshua Davis) wrote:
>>How can I read an ordinary binary file so I can make a manual installation
>>program?  ...
>Look in the documentation under File and BlockRead, BlockWrite. They will
>allow you to copy anything.

However, be aware that BlockRead and BlockWrite are tricky to use
properly, and frequently lead to bugs in your program.  (Don't believe
me?  Find a program that uses BlockRead to read a file.  Use the DOS
ATTRIB command to make the input file read-only, and I'd guess there's
a 90% chance that the program will not be able to read it, because by
default, it tries to open the file with read/write access, and most
people forget to change the default.)

You're better off using TDOSStream or TBufStream from the Objects
unit.  TDOSStream is about the same speed as BlockRead/BlockWrite,
TBufStream is either faster or slower depending on the situation.
Both of them make you specify what you want to do with the file when
you open it, so you don't make stupid mistakes like opening a file
with the wrong access mode.

Duncan Murdoch

Re:Binary Files...


In a previous article, dmurd...@mast.queensu.ca (Duncan Murdoch) wrote:

Quote
>However, be aware that BlockRead and BlockWrite are tricky to use
>properly, and frequently lead to bugs in your program.  (Don't believe
>me?  Find a program that uses BlockRead to read a file.  Use the DOS
>ATTRIB command to make the input file read-only, and I'd guess there's
>a 90% chance that the program will not be able to read it, because by
>default, it tries to open the file with read/write access, and most
>people forget to change the default.)

Pro noblem - just get the file attributes, change the ones you need to
change, do your file I/O, then restore (if you want to) the file
attributes.   Wrap this around all your file I/O routines - including
text file I/O.  

Better still, test the file attributes and if the file is a hidden,
read-only, or  system file ask the user an "Are you sure you want to
do this ..." type of question.  I do this regardless of whether I
am using streams or a BlockRead/BlockWrite file I/O method.

Quote
>You're better off using TDOSStream or TBufStream from the Objects
>unit.  TDOSStream is about the same speed as BlockRead/BlockWrite,
>TBufStream is either faster or slower depending on the situation.
>Both of them make you specify what you want to do with the file when
>you open it, so you don't make stupid mistakes like opening a file
>with the wrong access mode.

>Duncan Murdoch

If your program has to run on an 8086 or 8088 machine, you can bet your
buns that file I/O will be noticebly faster if you use BlockRead/BlockWrite
instead of streams.

I do advocate use of streams in many situations, and in particular I
refer a lot of people to Duncan's "streams" unit (available at garbo,
among other places ), but there are times when streams are not a wise
choice.

Rob Stow

Re:Binary Files...


On 3 MAY 96 15:46:59 GMT, s...@skyfox.usask.ca wrote:

Quote
>In a previous article, dmurd...@mast.queensu.ca (Duncan Murdoch) wrote:
>> Find a program that uses BlockRead to read a file.  Use the DOS
>>ATTRIB command to make the input file read-only, and I'd guess there's
>>a 90% chance that the program will not be able to read it, because by
>>default, it tries to open the file with read/write access, and most
>>people forget to change the default.)

>Pro noblem - just get the file attributes, change the ones you need to
>change, do your file I/O, then restore (if you want to) the file
>attributes.   Wrap this around all your file I/O routines - including
>text file I/O.  

?? That's not a great solution.  It's much better to open the file
with the right filemode, not to mess around with the attributes of the
file.  What if it's on a network drive and you're not allowed to
change the file attributes?

Quote
>>You're better off using TDOSStream or TBufStream from the Objects
>>unit.  TDOSStream is about the same speed as BlockRead/BlockWrite,
>>TBufStream is either faster or slower depending on the situation.
>>Both of them make you specify what you want to do with the file when
>>you open it, so you don't make stupid mistakes like opening a file
>>with the wrong access mode.
>If your program has to run on an 8086 or 8088 machine, you can bet your
>buns that file I/O will be noticebly faster if you use BlockRead/BlockWrite
>instead of streams.

That was definitely not true in the tests I ran several years ago.
TDOSStream and BlockRead were virtually tied; TBufStream was often
much faster (and also often much slower, it depends on what you do
with it); loading the whole file into EMS and using TEMSStream was
just about always faster (but of course, there weren't too many 8086
machines with hardware EMS cards, so this solution wasn't often
available).

Duncan Murdoch

Other Threads