我找到了以下解决方案来确定驱动器是否支持硬链接:
CString strDrive = _T("C:\\");
DWORD dwSysFlags;
if(GetVolumeInformation(strDrive, NULL, 0, NULL, NULL, &dwSysFlags, NULL, 0))
{
if((dwSysFlags & FILE_SUPPORTS_HARD_LINKS) != 0)
{
// Hard links can be created on the specified drive.
}
else
{
// Hard links cannot be created on the specified drive.
}
}
但是,根据MSDNFILE_SUPPORTS_HARD_LINKS
,直到 Windows Server 2008 R2 和 Windows 7 才支持该标志。
我还考虑过使用CreateHardLink()
它来尝试创建一个虚拟硬链接。如果创建了硬链接,那么我知道可以在相应的驱动器上创建硬链接。但是,我可能没有访问该驱动器的权限。在这种情况下,我假设这种方法会失败。
有谁知道如何确定驱动器是否支持 Windows XP 中的硬链接而不需要对该驱动器的写访问权限?