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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:56:03+00:00 2026-05-24T02:56:03+00:00

LockFile() does not have waiting timeout, LockFileEx() does not, either. If I want to

  • 0

LockFile() does not have waiting timeout, LockFileEx() does not, either.
If I want to wait for file-lock with timeout, how would I go about it?

That is, how do I implement the following:

DWORD LockFileTimed(HANDLE h,  
    DWORD milli,  
    __in  DWORD dwFileOffsetLow,  
    __in  DWORD dwFileOffsetHigh,  
    __in  DWORD nNumberOfBytesToLockLow,  
    __in  DWORD nNumberOfBytesToLockHigh)  
  • 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-24T02:56:04+00:00Added an answer on May 24, 2026 at 2:56 am

    I understand your intention of LockFileTimed as it will not return immediately when the file cannot be locked, but retry to lock the file for the given time. Is it right? It’s unclear whether this is what you want.

    A simple way to implement would be just writing a small loop to check the return code.

    DWORD timer_end = GetTickCount() + milli;
    while (GetTickCount() < timer_end) {
      if (LockFile(...))
        return TRUE;
      else
        Sleep(0); // Wait sometime.
    }
    return FALSE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Ant task which runs if the lock file is not existing.
I have a java program which creates a lock file to ensure that no
I have a FileMapping class that allows me to also lock a file for
How to lock file in Windows so that this file can be opened/read/wrote only
I have a script that I only want to be running one time. If
I have following problem. I want to create a file system based session storage
I want to see if a lock file modify date is more than a
I receive error FATAL: could not create lock file postmaster.pid: Permission denied when trying
Could anyone please help with a PHP lock file function ? I want to
I have a project with the following Gemfile.lock file http://pastie.org/private/tfbnteruyahmwfhtt26ea , and when I

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.