相关函数:
HANDLE FindFirstVolumeMountPoint(
                                                              LPTSTR lpszRootPathName,     // volume name
                                                              LPTSTR lpszVolumeMountPoint, // output buffer
                                                              DWORD cchBufferLength        // size of output buffer
                                                             );

BOOL FindNextVolumeMountPoint(
                                                             HANDLE hFindVolumeMountPoint,    // search handle
                                                             LPTSTR lpszVolumeMountPoint,     // output buffer
                                                             DWORD cchBufferLength            // size of output buffer
                                                        );

BOOL FindVolumeMountPointClose
                                                            HANDLE hFindVolumeMountPoint    // search handle
                                                          );

说明:
这几个函数都是与驱动器挂载点操作相关的,关于挂载点就不多介绍了,可以在磁盘管理中,选择更改驱动器号和路径里设置,设置后自己看看效果就理解挂载点的意思了。
这三个函数的使用和FindFirstVolume,
FindNextVolume,
FindVolumeClose函数的使用差不多,而这里用FindFirstVolume函数找到的卷名恰好可以做为FindFirstVolumeMountPoint的第一个参数,

所以他们可以一起使用,不过我测试过直接拿诸如“C:\\”的参数传到FindFirstVolumeMountPoint的第一个参数里也是可以成功的。

下面写一个测试代码:

int _tmain(int argc, _TCHAR* argv[])
{ CHAR szVolumeName[MAX_PATH] = { 0 };
CHAR szVolumeMountPoint[MAX_PATH] = { 0 }; HANDLE hVolume;
HANDLE hVolumeMountPoint;
//查找第一个驱动器名字
hVolume = FindFirstVolumeA(szVolumeName, MAX_PATH);
if (INVALID_HANDLE_VALUE == hVolume)
return 0;
printf("%s \n", szVolumeName);
//根据名字找挂载点
hVolumeMountPoint = FindFirstVolumeMountPointA(szVolumeName, szVolumeMountPoint, MAX_PATH);
if (INVALID_HANDLE_VALUE == hVolumeMountPoint)
{
FindVolumeClose(hVolume);
return 0;
}
while (FindNextVolumeMountPointA(hVolumeMountPoint, szVolumeMountPoint, MAX_PATH))
{
printf("%s \n", szVolumeMountPoint);
} while (FindNextVolumeA(hVolume, szVolumeName, MAX_PATH))
{
printf("%s \n", szVolumeName); hVolumeMountPoint = FindFirstVolumeMountPointA(szVolumeName, szVolumeMountPoint, MAX_PATH);
do
{
if (INVALID_HANDLE_VALUE == hVolumeMountPoint)
{
break;
} printf("%s \n", szVolumeMountPoint);
}
while (FindNextVolumeMountPointA(hVolumeMountPoint, szVolumeMountPoint, MAX_PATH));
}
FindVolumeClose(hVolume);
FindVolumeMountPointClose(hVolumeMountPoint);
}

分析:一般我们的机上子没有挂载点,所以上面的程序找不到挂载点,只能看到GetFirstVolume函数有返回值。不过可以手动设置挂载点,只要你设置挂载点后就会看到GetFirstVolumeMountPoint也会返回有效句柄了

Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint的更多相关文章

  1. windows API 第22篇 WTSGetActiveConsoleSessionId

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

  2. windows API 第13篇 MoveFileEx

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

  3. Windows API 第六篇 GetLocalTime

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

  4. Windows API 第三篇

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

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

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

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

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

  7. Windows API 第20篇 GetVolumeNameForVolumeMountPoint

    函数原型: BOOL GetVolumeNameForVolumeMountPoint(                                                        ...

  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. C++调用python(C++)

    C++源代码:python部分就是正常的python代码 #include <string.h> #include <math.h> #include "iostre ...

  2. 「题解」:X国的军队

    问题 A: X国的军队 时间限制: 1 Sec  内存限制: 256 MB 题面 题面谢绝公开. 题解 简单贪心. 按照存活的士兵数量(即参加战斗的士兵数量减去阵亡的士兵数量)排序. 若存活士兵数量相 ...

  3. MySQL 笔记一

    一.基本语法 1.数据库操作 create database [IF NOT EXIEST ] 数据库名   --创建数据库 drop database  数据库名                   ...

  4. 牛客多校第四场 J Free 最短路

    题意: 求最短路,但是你有k次机会可以把路径中某条边的长度变为0. 题解: 跑k+1次迪杰斯特拉,设想有k+1组dis数组和优先队列,第k组就意味着删去k条边的情况,每次松弛操作,松弛的两点i,j和距 ...

  5. VS2010-MFC(常用控件:滚动条控件Scroll Bar)

    转自:http://www.jizhuomi.com/software/191.html 滚动条控件简介 滚动条大家也很熟悉了,Windows窗口中很多都有滚动条.前面讲的列表框和组合框设置了相应属性 ...

  6. 第十七篇:csv拆分、csv转excel方法

    首先对微软的office功能表示敬佩!可能是这些办公软件太过平常化,所以体会不到他有多牛!csv格式数据以前没接触过,百度百科定义,Comma-Separated Values,CSV,逗号分隔值,或 ...

  7. R:ggplot2数据可视化——进阶(2)

    Part 2: Customizing the Look and Feel, 更高级的自定义化,比如说操作图例.注记.多图布局等  # Setup options(scipen=999) librar ...

  8. NEO4J全文检索架构

    NEO4J全文检索架构 一.有大量存量数据(亿级以上)(并长期有增量数据进入) 二.无大量存量数据或者少量存量数据(或全部为增量数据) 三.架构方案选择优先级 以下方案,是根据实践总结的基于NEO4J ...

  9. WPF实现Drag/Drop操作

    原文:WPF实现Drag/Drop操作 有时候我们方便用户操作,总会把一下Copy/Paste 或者 input操作转换为Drag/Drop, WPF 跟之前WinForm 一样提供了一些实现方式方便 ...

  10. 移植 thttpd Web 服务器

    下载 从 http://www.acme.com/software/thttpd/下载 thttpd 到/tmp 目录当中,并解压. 编译 thttpd [arm@localhost thttpd­2 ...