函数原型:

BOOL GetVolumeNameForVolumeMountPoint(
                                                                            IN  LPCTSTR lpszVolumeMountPoint, // volume mount point or directory
                                                                            OUT  LPTSTR lpszVolumeName,        // volume name buffer
                                                                            IN  DWORD cchBufferLength         // size of volume name buffer);

此函数根据挂载点或者根目录获取相关连的卷的唯一标志符(GUID),也就是得到像
\\?\Volume{fe04a016-a8fc-11e4-824b-806e6f6e6963}\ 这样的字符

The GetVolumeNameForVolumeMountPoint function takes a volume mount point
or root directory and returns the corresponding unique volume name.
举例:

1)传入更目录 

CHAR szVolumeName[MAX_PATH] = { 0 };

BOOL bRet = GetVolumeNameForVolumeMountPointA("C:\\", szVolumeName, MAX_PATH); 

2)传入一个已存在的卷的挂载点,假设设置了D盘的挂载点为 C:\test\

CHAR szVolumeName[MAX_PATH] = { 0 };

BOOL bRet = GetVolumeNameForVolumePountPointA("C:\\test\\, szVolumeName, MAX_PATH");

标注:

The lpszVolumeMountPoint input string may be a drive letter with
appended backslash (\), such as "D:\". Alternatively, it may be a path to a
volume mount point, again with appended backslash (\), such as
"c:\mnt\edrive\".

关于Unique Volume Name介绍:

Two factors can make it hard to reliably mount a specific volume at a
specified volume mount point across operating system restarts. One factor is
that two different volumes can have the same label, which makes them
indistinguishable except by drive letter. The other factor is that drive letters
do not necessarily remain the same. If a computer's administrator does not use
the Disk Administrator to enforce drive letters, then drive letters can change
as drives are removed from or added to the system.

To solve this problem, the system refers to volumes to be mounted with unique
volume names. These are strings of this form:

"\\?\Volume{GUID}\"

where GUID is a globally unique identifier (GUID) that identifies the
volume. The \\?\ turns off path parsing and is ignored as part of the
path, as discussed in Path Lengths. Note the
trailing backslash. All volume mount point functions that take a unique volume
name as a parameter require the trailing backslash; all volume mount point
functions that return a unique volume name provide the trailing backslash. You
can use CreateFile to open a volume by
referring to its unique volume name, but without a trailing backslash. When
using CreateFile, a unique volume name with a backslash refers to the
root directory of the volume.

The operating system assigns a unique volume name to a volume when the
computer first encounters it, for example during formatting or installation. The
volume mount point functions use unique volume names to refer to volumes. To
learn the unique volume name of any drive, use the GetVolumeNameForVolumeMountPoint function.

Windows API 第20篇 GetVolumeNameForVolumeMountPoint的更多相关文章

  1. Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误

    函数原型:BOOL SetVolumeMountPoint(                                                   IN   LPCTSTR lpszVo ...

  2. windows API 第22篇 WTSGetActiveConsoleSessionId

    函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...

  3. windows API 第13篇 MoveFileEx

    上一篇介绍了MoveFile,这次分析MoveFileEx,它是MoveFile的扩展函数,功能还要更加强大些.先看定义: BOOL WINAPI MoveFileEx( _In_     LPCTS ...

  4. Windows API 第六篇 GetLocalTime

    GetLocalTime获取系统时间信息.函数原型:VOID   WINAPI  GetLocalTime(    __out LPSYSTEMTIME lpSystemTime    ); 先来看S ...

  5. Windows API 第三篇

    1.获得程序自身的路径: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // pat ...

  6. Windows API 第21篇 DeleteVolumeMountPoint 删除挂载点

    函数原型:BOOL DeleteVolumeMountPoint(                                                      LPCTSTR lpszV ...

  7. Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint

    相关函数:HANDLE FindFirstVolumeMountPoint(                                                               ...

  8. windows API 第 18篇 FindFirstVolume FindNextVolume

    函数定义:Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the vol ...

  9. Windows API 第17篇 GetLogicalDriveStrings 获取本机所有逻辑驱动器,以根目录的形式表示

    函数原型:DWORD GetLogicalDriveStrings(  DWORD nBufferLength,  // size of buffer                          ...

随机推荐

  1. Android 开发 框架系列 OkHttp拦截器

    前言 此篇博客只讲解okhttp的拦截器功能的详细使用,如果你还不太了解okhttp可以参考我另外一篇博客 Android 开发 框架系列 OkHttp使用详解 添加Interceptor的简单例子 ...

  2. js实现F5键刷新后菜单保持之前状态以及监听F5页面刷新子iframe 而父页面不刷新

    利用layui实现菜单效果时,刷新页面仍回到首页状态,需要 实现iframe子页面刷新父元素不刷新,下面是代码 //刷新时禁用F5的默认事件 $(document).keydown(function ...

  3. 基于Maven的ssm(spring+springMvc+Mybatis)框架搭建

    前言 本demo是在idea下搭建的maven项目,数据库使用Mysql,jdk版本是1.8.0_171,ideal:2017.3.5 一.新建项目 1.file->new->porjec ...

  4. (转)Android 自定义标题栏(title栏)

    转:http://blog.csdn.net/jamin0107/article/details/6715678 第一步,向实现自定义标题栏,需要在onCreate方法里这样写 requestWind ...

  5. 命令学习_ping

    PING: ping是一个所有操作系统都支持的简单工具.我么可以利用ping来解析DNS 的A record和PTRrecord. A记录是将域名映射到IP地址,这个是ping的缺省功能, ping同 ...

  6. iOS开发NSLayoutConstraint代码自动布局

    1.NSLayoutConstraint简介 适配界面大多用Masonry工具,也是基于NSLayoutConstraint写的!通过使用两个类方法实现自动布局: + (NSArray<__ki ...

  7. MongoDB错误记录

    文章目录 mongoDB启动报错 mongoDB启动报错 在bin目录下执行 ./mongod 报错如下 F CONTROL [main] Failed global initialization: ...

  8. 小tips: zoom和transform:scale的区别

    小tips: zoom和transform:scale的区别 转自 张鑫旭 前端大神 by zhangxinxu from http://www.zhangxinxu.com本文地址:http://w ...

  9. P1020 导弹拦截 /// DP Dilworth定理 LIS、LDS优化

    题目大意: https://www.luogu.org/problemnew/show/P1020 Dliworth有两个互相对偶的定理:U的链划分使用的最少集合数,等于它的最大反链长度.(1)U的反 ...

  10. typeerror: __init__() missing 2 required positional arguments: 'inputs' and 'outputs'

    1 问题描述 使用下边这条命令去检查 TensorFlow Object Detection API是否正确安装: python object_detection\builders\model_bui ...