函数原型:

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. layui点击按钮自动刷新页面问题

    问题 <button class="layui-btn layui-btn-primary" onclick="findData()">查询< ...

  2. CF1086F Forest Fires

    CF1086F Forest Fires 有点意思的题目 直接统计每个格子的val是非常难办的.很难知道每秒新出来多少个格子 设$F[i]$表示,前i时刻覆盖的格子的数量 则,$ans=\sum_{i ...

  3. HTTP协议响应篇

    http响应的基本介绍 一个HTTP响应代表服务器向客户端回送的数据, 由三个部分构成 状态行[200 , 302 304, 403, 404, 500] 响应消息头 返回的实体内容 http响应状态 ...

  4. 开发笔记-19/10/28 -SpringBoot @Value 获取配置参数

    1. 在application.properties 定义参数 role.taskEvent :参数名称 4:值 ## ---------------------任务角色--------------- ...

  5. 重写、super关键字、final关键字、多态、子类型转换、抽象的初步了解

    重写 含义 在Java中,子类可继承父类中的方法,而不需要重新编写相同的方法.但有时子类并不想原封不动地继承父类的方法,而是想作一定的修改,这就需要采用方法的重写.方法重写又称方法覆盖. 重写与重载的 ...

  6. django零散知识点

    后端将对象以对象形式传到前端: from django.core.serializers import serialize def xxx(reqeust): project_list = model ...

  7. T3118 01完美矩阵【计数,前缀和,差分,好题】

    Online Judge:未知 Label:好题,计数,前缀和 题目描述 一个01矩形被称为是完美01矩形,如果满足下面3个条件: (1)它的四条边上都是1 (2)内部(除了4条边)的0和1的个数之差 ...

  8. C++ 系列:extern

    extern 作用1:声明外部变量现代编译器一般采用按文件编译的方式,因此在编译时,各个文件中定义的全局变量是互相透明的,也就是说,在编译时,全局变量的可见域限制在文件内部. 例1:创建一个工程,里面 ...

  9. Vagrant box ubuntu/xenial64 添加vagrant用户解决没有登录密码的问题

    参考了Vagrant box ubuntu/xenial64 の ubuntuユーザ の passwordについて 1. 可以通过 Git Bash 使用  vagrant ssh 登录到Ubuntu ...

  10. activeMQ消息队列安装配置

    1.  下载 到官网下载最新版本,有windows版本和linux版本的. http://activemq.apache.org/download.html 2.   windows下部署 Activ ...