Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint
相关函数:
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的更多相关文章
- windows API 第22篇 WTSGetActiveConsoleSessionId
函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...
- windows API 第13篇 MoveFileEx
上一篇介绍了MoveFile,这次分析MoveFileEx,它是MoveFile的扩展函数,功能还要更加强大些.先看定义: BOOL WINAPI MoveFileEx( _In_ LPCTS ...
- Windows API 第六篇 GetLocalTime
GetLocalTime获取系统时间信息.函数原型:VOID WINAPI GetLocalTime( __out LPSYSTEMTIME lpSystemTime ); 先来看S ...
- Windows API 第三篇
1.获得程序自身的路径: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // pat ...
- Windows API 第21篇 DeleteVolumeMountPoint 删除挂载点
函数原型:BOOL DeleteVolumeMountPoint( LPCTSTR lpszV ...
- Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误
函数原型:BOOL SetVolumeMountPoint( IN LPCTSTR lpszVo ...
- Windows API 第20篇 GetVolumeNameForVolumeMountPoint
函数原型: BOOL GetVolumeNameForVolumeMountPoint( ...
- windows API 第 18篇 FindFirstVolume FindNextVolume
函数定义:Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the vol ...
- Windows API 第17篇 GetLogicalDriveStrings 获取本机所有逻辑驱动器,以根目录的形式表示
函数原型:DWORD GetLogicalDriveStrings( DWORD nBufferLength, // size of buffer ...
随机推荐
- mysql用户管理和pymysql
mysql用户管理 为了使不同的人员访问到对应身份的数据库资源,每个人都有不同的权限. mysql本质上是一款cs软件,它具备用户认证,那么如何实现呢?那就是写入文件,但是在mysql把文件称作表,只 ...
- mysql重点,表查询操作和多表查询
表单查询 1. 完整的查询语句语法 select distinct(* or 字段名 or 四则运算 )from 表名 where 条件 group by 条件 having 条件 order by ...
- JSF(JavaServer Faces)简介
JavaServer Faces (JSF) 是一种用于构建Java Web 应用程序的标准框架(是Java Community Process 规定的JSR-127标准).它提供了一种以组件为中心的 ...
- The Python Standard Library
The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...
- HDU-3068-最长回文-马拉车算法模板题
给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input输入有多组case,不超过120组,每组输入为 ...
- java设计模式系列1-- 概述
准备开始写些设计模式的随笔,这是第一篇,概述主要回顾下六大原则 先用轻松和谐的语言描述下这6个原则: 单一职责 每个类甚至每个方法都只要做自己分内的事,不要背别人的锅,也就是功能要分类,代码要解耦 里 ...
- POJ 1269 /// 判断两条直线的位置关系
题目大意: t个测试用例 每次给出一对直线的两点 判断直线的相对关系 平行输出NODE 重合输出LINE 相交输出POINT和交点坐标 1.直线平行 两向量叉积为0 2.求两直线ab与cd交点 设直线 ...
- Python全栈开发:web框架
Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 ...
- Python全栈开发:冒泡排序
#!/usr/bin/env python # -*- coding;utf-8 -*- """ 第一次对比:找到最大值,放到最后 对比是两两对比,对比的两个数组合共有l ...
- SpringMVC参数绑定(未完待续)
1. Strut2与SpringMVC接收请求参数的区别 Struts2通过action类的成员变量接收SpringMVC通过controller方法的形参接收 2. SpringMVC参数绑定流程 ...