Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
WriteFile()
API 函数存在错误,这实在令人难以置信。下一步必须检查错误代码并在函数失败时调用GetLastError()
。It's pretty implausible that the
WriteFile()
API function has a bug. Your next step must be to check error codes and callGetLastError()
when the function fails.可能导致这种情况的一件事是:
One possible thing that can lead to that is :
在我们的例子中,WriteFile 函数失败了,因为我们在计时器中调用了该函数。线程中有另一个函数正在并行线程中调用 ReadFile(并访问同一文件)。由于 WriteFile 在该实例中无法访问该文件,因此它曾经失败!
WriteFile function in our case was failing because we had called the function in the timer. There was another function in a thread which was calling ReadFile (and accessing the same file) in a parallel thread. Since the WriteFile did not get the access to the file at that instance, it used to fail!