英文:
How do I exclusively lock a file on Windows?
问题
我想在Windows环境下独占锁定文件,但是syscall.Flock
在Windows上不受支持。有没有办法实现它?
我尝试了这篇文章的方法,但是它不起作用(syscall.Syscall6
引发了"Access is denied."错误)。
英文:
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 <a href="http://ikarishinjieva.github.io/tachikoma-blog/post/2014-03-20-go-file-lock/">this article</a>'s method however it doesn't work (syscall.Syscall6
raises "Access is denied." error).
答案1
得分: 1
Windows的C++ API可以帮助你。LockFile和LockFileEx函数似乎足够帮助你。
英文:
Windows c++ api could help you. The LockFile and LockFileEx functions seem enough to help.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论