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

  • SEARCH
  • Home
  • 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 3242014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:15:55+00:00 2026-05-17T18:15:55+00:00

I have found that if you open a file that resides on 32 bit

  • 0

I have found that if you open a file that resides on 32 bit server in a share folder from a 64 bit windows 7 machine, read it, lock it and then open it again. When you close all open handles the file actually remains open.

The exact steps are:

  1. Place a file that is between 7000 and 10000 bytes long in a shared folder on a 32 bit windows machine, we are using Windows Server 2003.

  2. Compile the following code for Win32 so that it runs under WOW64. Please note that I’ve missed out try..finally, declarations, etc for simplicity.
    (see code fragment below; a StackOverflow bug does not format code correctly when it is inside a list)

  3. Run the application on a 64 bit windows machine. the file must be on a 32 bit machine, we use windows server 2003, the bug does not occur if the file is on a 64 bit server.

  4. Terminate your application.

  5. If you now open up the computer manager on the server (control panel->computer management) and look at the opened files in the share folder where your file resides you will see that your file is still open.

This is the code:

procedure CauseFileLockBug(FileName: PChar);
var
  FileHandle1: LongInt;
  FileHandle2: LongInt;
  Buffer: Pointer;
  BytesRead: Cardinal;
begin
  FileHandle1 := CreateFile(
    FileName, 
    GENERIC_READ or GENERIC_WRITE, 
    FILE_SHARE_READ or FILE_SHARE_WRITE, 
    nil, 
    OPEN_EXISTING, 
    FILE_FLAG_RANDOM_ACCESS, 
    0);

  if FileHandle1 > 0 then
  begin
    try
      GetMem(Buffer, 1);

      try
        if ReadFile(FileHandle1, Buffer^, 1, BytesRead, nil) then
        begin
          if LockFile(FileHandle1, 6217, 0, 1, 0) then
          begin
            try
              FileHandle2 := CreateFile(
                FileName, 
                GENERIC_READ or GENERIC_WRITE, 
                FILE_SHARE_READ or FILE_SHARE_WRITE, 
                nil, 
                OPEN_EXISTING, 
                FILE_FLAG_RANDOM_ACCESS, 
                0);

              if FileHandle2 > 0 then
              begin
                CloseHandle(FileHandle2);
              end;
            finally
              UnLockFile(FileHandle1, 6217, 0, 1, 0);
            end;
          end;
        end;
      finally
        FreeMem(Buffer);
      end;
    finally
      CloseHandle(FileHandle1);
    end;
  end;
end;

The problem goes does not occur if you use the FILE_FLAG_NO_BUFFERING flag when opening the file the second time or if you do not read the file before locking it.

Has anyone noticed this before or know how to solve it, without using the FILE_FLAG_NO_BUFFERING? Please not that it only happens when a 64 bit windows client opens a file in this way on a 32 bit windows machine, it does not occur with 32 to bit or 64t to 64.

  • 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-17T18:15:56+00:00Added an answer on May 17, 2026 at 6:15 pm

    Ok Problem solved.

    Seems like Nod32 x64 was causing the issue. Adding all possible paths into the folder (all network paths and mapped drives) to the exclusions list with wildcard * and then rebooting the PC has fixed it.

    Anyway thanks for your help.

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

Sidebar

Related Questions

I found out that in order to open a Gmail compose screen you'd have
I have found that creating a zip file using the Zip task provided by
I have a SQL Server CE Database file that gets re-deployed every time I
Hey everyone, I have written a script that downloads a zip file from a
When I open a file for reading in Haskell, I've found that I can't
I have been trying to lock a file so that other cloned services cannot
I have found that how to determine what columns are primary key column of
I have found that I often have to implement some sort of a scheduler
We have found that with our memcache some keys tend to be lost. To
I have found that dragend event in Google Map also trigger the click event

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.