在Windows中从文件名获取驱动器号 [英] Get drive letter from filename in Windows

查看:290
本文介绍了在Windows中从文件名获取驱动器号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有Windows API函式从Windows路径撷取驱动器号,例如

Is there a Windows API function to extract the drive letter from a Windows path such as

U:\path\to\file.txt
\\?\U:\path\to\file.txt

正确排序

relative\path\to\file.txt:alternate-stream    

etc?

推荐答案

PathGetDriveNumber 返回0到25(对应于'A'到'Z'),如果路径有一个驱动器号,否则为-1。

PathGetDriveNumber returns 0 through 25 (corresponding to 'A' through 'Z') if the path has a drive letter, or -1 otherwise.

这篇关于在Windows中从文件名获取驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆