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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:32:44+00:00 2026-05-26T08:32:44+00:00

I have a problem understanding how to use the API function CreateFileMapping(…) . I’ve

  • 0

I have a problem understanding how to use the API function CreateFileMapping(...).

I’ve been trying to map a small file and then reverse it’s content. It has only about 1 Kb, but I keep getting the “Not enough memory” error.

I have opened the file by calling CreateFile and got it’s size with GetFileSize.

Then I call:

CreateFileMapping(fileHandle, 
                  NULL, 
                  PAGE_READWRITE | SEC_RESERVE, 
                  fileSize + 1, 
                  fileSize + 1, 
                  NULL);

I suspect that the problem is with passing the fileSize + 1 as dwFileOffsetHighand dwFileOffsetLow, but I have a hard time understanding what should I pass to it instead.

Any hints are greatly appreciated!

  • 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-05-26T08:32:45+00:00Added an answer on May 26, 2026 at 8:32 am

    dwFileOffsetHigh and dwFileOffsetLow are two 32 bit values that are combined to form a single 64 bit value. This function was implemented this way because it pre-dates widespread compiler support for 64 bit values.

    I think your misunderstanding is in believing that the high and low mean upper and lower limits.

    In your case your value (assuming fileSize is around 1KB) is nowhere near requiring 64 bits so you should pass fileSize+1 for dwFileOffsetLow and 0 for dwFileOffsetHigh.

    However, if you are attempting to map the entire file you can simply pass 0 for both parameters.

    From the documentation:

    dwMaximumSizeHigh [in]

    The high-order DWORD of the maximum size of the
    file mapping object.

    dwMaximumSizeLow [in]

    The low-order DWORD of the maximum size of the
    file mapping object.

    If this parameter and dwMaximumSizeHigh are 0 (zero), the maximum size
    of the file mapping object is equal to the current size of the file
    that hFile identifies.

    An attempt to map a file with a length of 0 (zero) fails with an error
    code of ERROR_FILE_INVALID. Applications should test for files with a
    length of 0 (zero) and reject those files.

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

Sidebar

Related Questions

I have some small problem in understanding Value Objects in Flex... I'm trying to
I have a small understanding problem with the heap in c++. I have created
I seem to have a problem understanding how to conditionally test a boolean value
I think I have a problem in understanding the proper way of using MVC.
I have an understanding problem of how the following code works: XMLInputFactory xif =
There are many skills a programmer could have (understanding the problem, asking good questions,
Possible Duplicate: Objective-C - When to use 'self' I am having problem understanding the
Let's start from simple introduction. For better understanding my problem I have drastically simplifield
I'm trying to get a better understanding of what place (if any) Macros have
I have a problem in understanding how the winapi condition variables work. On the

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.