Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:45:33+00:00 2026-06-15T02:45:33+00:00

how in Delphi could I open binary file in non-text mode? Like C function

  • 0

how in Delphi could I open binary file in non-text mode?
Like C function fopen(filename,"rb")

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:45:34+00:00Added an answer on June 15, 2026 at 2:45 am

    There are a few options.

    1. Use a file stream

    var
      Stream: TFileStream;
      Value: Integer;
    ....
    Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
    try
      Stream.ReadBuffer(Value, SizeOf(Value));//read a 4 byte integer
    finally
      Stream.Free;
    end;
    

    2. Use a reader

    You would combine the above approach with a TBinaryReader to make the reading of the values simpler:

    var
      Stream: TFileStream;
      Reader: TBinaryReader;
      Value: Integer;
    ....
    Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
    try
      Reader := TBinaryReader.Create(Stream);
      try
        Value := Reader.ReadInteger;
      finally
        Reader.Free;
      end;
    finally
      Stream.Free;
    end;
    

    The reader class has lots of functions to read other data types. And you can go in the opposite direction with a binary writer.

    3. Old style Pascal I/O

    You can declare a variable of type File and use AssignFile, BlockRead, etc. to read from the file. I really don’t recommend this approach. Modern code and libraries almost invariably prefer the stream idiom and by doing the same yourself you’ll make your code easier to fit with other libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please how could this C++ function be converted to Delphi : int To_Asm_Fnc(dword Amem,
Scenario: Delphi did a non-normal shutdown. When I restarted I got the messages Could
Could someone please shed some light on this behaviour? It looks like Delphi SOAP
In the Delphi 2007 IDE, I'm hoping there's a configuration option I could turn
// delphi code (delphi version : Turbo Delphi Explorer (it's Delphi 2006)) function GetLoginResult:PChar;
Delphi 2010 has a nice set of new file access functions in IOUtils.pas (I
Has anyone successfully used WebKit in Delphi? WebKit is an open source web browser
Could this problem also apply to Delphi applications running on Terminal Servers? As the
Consider this part of code: Try arqTXT.LoadFromFile(LogPath); finally ShowMessage( The log file could not
I could probably code quickest in Delphi - any examples? Failing that, I guess

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.