I found the following solution to determine whether a drive supports hard links:
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.
}
}
However, according to MSDN the flag FILE_SUPPORTS_HARD_LINKS
is not supported until Windows Server 2008 R2 and Windows 7.
I also thought about using CreateHardLink()
in order to try to create a dummy hard link. If the hard link is created then I know that creating hard links on the corresponding drive is possible. However, it may happen that I have no access rights to the said drive. In this case I assume that this method would fail.
Does anybody know how to determine whether a drive supports hard links in Windows XP without requiring write access to that drive?