函数原型:

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. 关于jquery.validate.js的用法

    // 手机号码验证 jQuery.validator.addMethod("isMobile", function(value, element) {   var length = ...

  2. 校园商铺-4店铺注册功能模块-8店铺注册之Controller层的改造

    不合理的地方: 1. 并不需要将InputStream转换成File类型,直接将InputStream传进入交给CommonsMultipartfile去处理就可以了 如果做这样的转换,每次都需要生成 ...

  3. django笔记(python web框架)

    1.Python 下载地址:https://www.python.org/downloads/ 2.Django 下载地址:https://www.djangoproject.com/download ...

  4. 树上思维题——cf1060E

    只要算每条路径的贡献即可 显然长度为偶数的贡献是len/2 长度为奇数的贡献是(len+1)/2 所以结果就是(sum+tot)/2 sum:路径总长 tot:奇数路径数量 怎么求奇数路径数量:只有深 ...

  5. VS2010-MFC(菜单:菜单及CMenu类的使用)

    转自:http://www.jizhuomi.com/software/212.html 上一节讲的是VS2010的菜单资源,本节主要讲菜单及CMenu类的使用. CMenu类的主要成员函数 MFC为 ...

  6. Invalid argument value:无效参数值。原因是:把Session值user0当做username作为参数了。 而实际上此时username是user0的成员变量。参数应该是user0.getUsername();然后发现别人的List得加泛型,我的怎么不用加,运行报错,上网收了错误原因,因为导包错误,不小心导错包了,改为util.List包对了。

  7. Mysql优化系列之索引性能

    实际上,前面的数据类型和表结构设计优化不能算优化,只能算规范,也就是说在设计表的时候,应该且必须做到这些 索引是sql优化的核心部分,在<高性能Mysql>中单独抽出一章讲,也印证了其重要 ...

  8. 微信小程序 主题皮肤切换(switch开关)

    示例效果: 功能点分析: 1.点击switch开关,切换主题皮肤(包括标题栏.底部tabBar):2.把皮肤设置保存到全局变量,在访问其它页面时也能有效果3.把设置保存到本地,退出应用再进来时,依然加 ...

  9. 1.1_springboot2.x与缓存原理介绍&使用缓存

    一.springboot与缓存介绍&使用缓存 1.JSR107 JAVA Cahing定义了5个核心接口,分别是CachingProvider.CacheManager.Cache.Entry ...

  10. <day001>存储到Mysql、mongoDB数据库+简单的Ajax请求+os模块+进程池+MD5

    任务1:记住如何存储到Mysql.mongoDB数据库 ''' 存储到Mysql ''' import pymysql.cursors class QuotePipeline(object): def ...