zoukankan      html  css  js  c++  java
  • Windows API 第20篇 GetVolumeNameForVolumeMountPoint

    函数原型:

    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:	est
    
    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:mntedrive".

    关于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.

  • 相关阅读:
    Python网页信息采集:使用PhantomJS采集淘宝天猫商品内容
    让Scrapy的Spider更通用
    API例子:用Python驱动Firefox采集网页数据
    API例子:用Java/JavaScript下载内容提取器
    Python即时网络爬虫:API说明
    Python: xml转json
    git 更新本地代码
    数据库事务
    Python的线程、进程和协程
    Java基础语法
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9755473.html
Copyright © 2011-2022 走看看