函数getDrivetyPew总是返回drive_no_root_dir
如标题所说,标准Windows 返回所有通过路径的值1(驱动器_no_root_dir)。
文档说
根路径无效;例如,没有安装的音量 指定的路径。
尽管我很确定所提供的路径(例如“ c:\\ temp”,“ c:\\ temp”)是有效的,并且固定驱动器(硬盘)。
我想念什么吗?什么可能导致这个?任何帮助都将不胜感激 - 我对Winapi并不熟悉。
bool FileAttributesRetriever::IsExternalPath(const std::filesystem::path& path)
{
uint32_t driveType = GetDriveTypeW(path.wstring().c_str()); // Always 1 / DRIVE_NO_ROOT_DIR
switch (driveType)
{
case DRIVE_REMOTE: // Network storage.
case DRIVE_REMOVABLE: // External drive.
{
return true;
}
default:
{
return false;
}
}
}
As title says, standard Windows GetDriveTypeW returns value 1 (DRIVE_NO_ROOT_DIR) for all passed paths.
Documentation says
The root path is invalid; for example, there is no volume mounted at
the specified path.
Although I'm pretty sure the supplied paths (e.g. "C:\\temp", "c:\\temp") is valid and is fixed drive (hard disk).
Am I missing something? What could possibly cause this? Any help would be appreciated - I'm not very familiar with WinAPI.
bool FileAttributesRetriever::IsExternalPath(const std::filesystem::path& path)
{
uint32_t driveType = GetDriveTypeW(path.wstring().c_str()); // Always 1 / DRIVE_NO_ROOT_DIR
switch (driveType)
{
case DRIVE_REMOTE: // Network storage.
case DRIVE_REMOVABLE: // External drive.
{
return true;
}
default:
{
return false;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档还表明,该论点必须是:
也就是说,如果要检查c:drive或
c:\ temp \
,则应使用c:\
调用它。想要检查以c:\ temp
安装的驱动器。The documentation also says that the argument must be:
That is you should call it with
C:\
if you want to check the C: drive, orC:\temp\
if you want to check the drive mounted atC:\temp
.