开发者

How to check with WINAPI file path is disk or file or directory?

开发者 https://www.devze.com 2023-01-12 14:58 出处:网络
How to check with WINAPI filepath is disk or file or开发者_Go百科 directory?Use GetFileAttributes.

How to check with WINAPI file path is disk or file or开发者_Go百科 directory?


Use GetFileAttributes.

Edit: You can also check SHGetFileInfo


Could try FindFirstFile:

http://msdn.microsoft.com/en-us/library/aa364418%28v=VS.85%29.aspx

Once you have the find data (passed as the 2nd argument to that function):

if(result->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
    //file is a directory
}
else
{
    //file is not a directory
}

Also, to see if something is a volume, could try something like:

if(result->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
{
    if(result->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)
    {
        //path is a volume; try using GetVolumeNameForVolumeMountPoint for info
    }
}

HTH


See if the path has a drive letter in front of it? All UNC's take the form "\\server\share\file_path" No drive letter.

Out of curiousity I looked this up. Based on this MSDN article Naming Files, Paths, and Namespaces, it seems my advice is exactly how it says it should be done.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号