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 ...
随机推荐
- div中内容可左右上下滑动
在<table>外套一层<div>,并且声明overflow:scroll属性,如: <div style="width:1620px;height:680px ...
- js和jQuery以及ajax的小练习
今天学习了通过鼠标的点击事件然后让边框变颜色,还有怎么设置一个点击浏览器的输入框然后显示一个边框,还学习了通过ajak来获取post和get的值,通过它如何调用这个函数. 第一部分: 通过鼠标的点击让 ...
- (转)JNI入门教程之HelloWorld篇 .
转: http://blog.csdn.net/mingjava/article/details/180946 本文讲述如何使用JNI技术实现HelloWorld,目的是让读者熟悉JNI的机制并编写第 ...
- 尚学linux课程---8、rpm软件包安装
尚学linux课程---8.rpm软件包安装 一.总结 一句话总结: rpm安装软件包的话要解决依赖问题,推荐使用yum安装软件包 1.比如cd /home中的斜线表示什么意思? 表示根目录,linu ...
- PHP实现对短信验证码发送次数的限制
http://www.jb51.net/article/94878.htm 对用户获取短信验证码的手机号.ip.和浏览器(使用唯一标识)进行限制.本文介绍的方法是对用户每天只能通过同一浏览器或同一ip ...
- mysql mac客户端: sequel,mysql-workbench
sequel: https://sequelpro.com/download#auto-start mysql-workbench:https://dev.mysql.com/downloads/fi ...
- JAXB注解使用
一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccesso ...
- selenium基础(鼠标和键盘事件)
selenium鼠标和键盘的操作事件 webdriver常见的几种操作方法 clear():清楚文本文字 send_keys(values):模拟按键输入,values是输入的内容 click():单 ...
- Java后端WebSocket的Tomcat实现(转)
文章摘要随着互联网的发展,传统的HTTP协议已经很难满足Web应用日益复杂的需求了.近年来,随着HTML5的诞生,WebSocket协议被提出,它实现了浏览器与服务器的全双工通信,扩展了浏览器与服务端 ...
- iOS开发系列-NSURLSession
概述 NSURLSession是从iOS7开始出现的.NSURLSession比NSURLConnection简单很多并且避免了很多坑,因此目前公司项目大部分由NSURLConnection过度为NS ...