Win32 相当于 opendir
有人知道 opendir 的 Win32 等价物是什么(或者它是否存在)? 显然我可以将 FindFirstFile(Ex) 与 FindNextFile 一起使用,但将 * 附加到路径似乎是一种很黑客的方式。
Would anyone know what the Win32 equivalent of opendir is (or if it even exists) ?
Obviously I could use FindFirstFile(Ex) with FindNextFile, but appending * to the path seems like such a hackish way to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
FindFirstFile
和FindNextFile
是适当的 Win32 API。 假设您正在编写 C++ 代码,作为一种可移植的替代方案,您可以考虑使用 Boost Filesystem 库(在 Windows 上使用FindFirstFile
和FindNextFile
实现)。FindFirstFile
andFindNextFile
are the appropriate Win32 APIs. Assuming you're writing C++ code, as a portable alternative you could consider usingdirectory_iterator
from the Boost Filesystem library (which is implemented on Windows usingFindFirstFile
andFindNextFile
).我相信您可以使用
CreateFile
与FILE_FLAG_BACKUP_SEMANTICS
,然后BackupRead
读取目录数据,但我不确定数据实际采用的格式。此外,您需要以具有SE_BACKUP_NAME 的用户身份运行
权限已启用,因此这并不适合通用应用程序。I believe you can use
CreateFile
withFILE_FLAG_BACKUP_SEMANTICS
and thenBackupRead
to read directory data, but I'm not sure what format the data is actually in. Also, you would need to be running as a user with theSE_BACKUP_NAME
privilege enabled, so this is not really suitable in a general purpose application.