CreateFile 返回负句柄
为什么 createfile() 函数会返回 -1 的任何想法。
Handle = CreateFile(filename, &H80000000, 0, 0, 3, &H80, 0)
这要运行几次。我在想也许文件没有正确关闭?
编辑
Err.LastllError 返回 32。
Any ideas why the createfile() function would be returning -1.
Handle = CreateFile(filename, &H80000000, 0, 0, 3, &H80, 0)
This is run a few times. I was thinking perhaps maybe the file is not being closed properly?
EDIT
Err.LastllError returns 32.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您关于不关闭某个地方的文件的说法可能是正确的。我首先会查看打开文件的位置,并确保有适当的错误处理例程。在错误处理程序中,我将检查“Handle”的值,如果它有效,则调用 CloseHandle(Handle)。此外,由于您要打开文件进行读访问,因此您可以将 dwShareMode 参数更改为 1,以允许后续打开同一文件进行读操作。
You are probably right about not closing the file someplace. I would start by looking where I am opening the file and making sure I have an error handling routine in place. In the error handler I would check the value of "Handle" and if it's valid call CloseHandle(Handle). Also, since you are opening the file for read access, you could change you dwShareMode parameter to 1 to allow subsequent open for read operations on the same file.
错误 32 是 ERROR_SHARING_VIOLATION(参考< /a>) 这意味着其他进程仍然打开该文件。
Error 32 is ERROR_SHARING_VIOLATION (reference) which means some other process still has the file open.