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)
I understand your intention of
LockFileTimedas 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.