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 8677927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:35:19+00:00 2026-06-12T20:35:19+00:00

I got two questions about ReadFile function from Win32 API. First of all, given

  • 0

I got two questions about ReadFile function from Win32 API. First of all, given that

BOOL WINAPI ReadFile(
                       _In_         HANDLE hFile,
                       _Out_        LPVOID lpBuffer,
                       _In_         DWORD nNumberOfBytesToRead,
                       _Out_opt_    LPDWORD lpNumberOfBytesRead,
                       _Inout_opt_  LPOVERLAPPED lpOverlapped
                    );

the third and fourth parameters are of type DWORD, which can hold maximum 1^32 without overflow. Does it mean that the ReadFile can only read a file that has less than 1^32 bytes data at a time? If that is true, I want to read a file bigger than 1^32, I’ll put the ReadFile in a loop like this

char buffer[1<<32];
while(!EOF){
  ReadFIle(filename,buffer,1^32,bytesout,NULL);
  SomeFunctionToExtractDataFromBuffer(buffer)
}

Supposed the loop tends to overwrite the buffer every iteration, in order for this design to work, the ReadFile needs to remember where the previous read happened in the file is this true? or there are other ways to achieve this. Thanks a lot

  • 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-12T20:35:20+00:00Added an answer on June 12, 2026 at 8:35 pm

    The third and fourth parameters are of type DWORD, which can hold
    maximum 1^32 without overflow. Does it mean that the ReadFile can only
    read a file that has less than 1^32 bytes data at a time?

    No. It means that it can only read up to 2^32 bytes in one go. There’s noone stopping you from calling ReadFile multiple times to read a total of as many bytes as you like (each read will advance the file pointer, so it will begin reading from the point where the previous read stopped).

    Supposed the loop tends to overwrite the buffer every iteration, in
    order for this design to work, the ReadFile needs to remember where
    the previous read happened in the file is this true?

    Yes, the OS remembers this for every open file (see file pointer link above).

    While on the subject I should mention that if you are scheduling 4GB reads then you are most likely doing something wrong. No matter what the nature of your data is, surely you can process it in smaller chunks and this will help not run up against a variety of problems such as available memory.

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

Sidebar

Related Questions

I've got two questions about the Perl open function: 1) I seem to remember
I've got some questions about two ways to save settings in the web.config. Appsettings
I've got two questions about Asp.Net MVC areas. I have only a shallow understanding
I've got two questions about LÖVE . Can I sell what I make in
With these two questions as background ( first and second ), I got curious
I just had a question about aligning two expand-collapse boxes and got an answer
I've got two questions (of which at least one is regarding RTTI in D2010
I've got question to you. I have got two project in PHP that uses
I'd like to ask about designing workflow merging. I've got several workflows that aren't
I've got a few questions about edittext.. I'm trying to create a login screen

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.