如何在Windows上独占锁定文件?

如何在Windows上独占锁定文件?

问题描述:

I want to lock file exclusively on Windows environment, but syscall.Flock isn't supported by Windows. Is there any way to implement it?

I tried this article's method however it doesn't work (syscall.Syscall6 raises "Access is denied." error).

我只想在Windows环境中锁定文件,但是 syscall.Flock code>不是 Windows支持。 有什么方法可以实现它? p>

我尝试了本文的方法,但是它不起作用( syscall.Syscall6 code>引发“访问被拒绝。”错误 )。 p> div>

Windows c++ api could help you. The LockFile and LockFileEx functions seem enough to help.