Best way to determine if two path reference to same file in Windows?

后端 未结 11 1654
生来不讨喜
生来不讨喜 2020-11-30 11:23

How would I compare 2 strings to determine if they refer to the same path in Win32 using C/C++?

While this will handle a lot of cases it misses some things:

11条回答
  •  时光说笑
    2020-11-30 11:48

    Open both files with CreateFile, call GetFileInformationByHandle for both, and compare dwVolumeSerialNumber, nFileIndexLow, nFileIndexHigh. If all three are equal they both point to the same file:

    GetFileInformationByHandle function

    BY_HANDLE_FILE_INFORMATION Structure

提交回复
热议问题