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 ...
随机推荐
- Java Collection - 遍历map的几种方式
作者:zhaoguhong(赵孤鸿) 出处:http://www.cnblogs.com/zhaoguhong/ 本文版权归作者和博客园共有,转载请注明出处 ---------------- 总结 如 ...
- Jupyter notebook文件默认存储路径以及更改方法
1.文件默认存储路径怎么查? 安装Anaconda后,新建文件的默认存储路径一般在C系统盘,那么路径是什么呢? 首先,新建一个.ipynb文件, 输入以下脚本,运行出的结果即是当前jupyter文件 ...
- thinkphp 模型实例化
在ThinkPHP中,可以无需进行任何模型定义.只有在需要封装单独的业务逻辑的时候,模型类才是必须被定义的,因此ThinkPHP在模型上有很多的灵活和方便性,让你无需因为表太多而烦恼. 根据不同的模型 ...
- hadoop快照管理
快照相当于对目录做备份,并不会复制所有文件,而是记录文件的变化命令用法 ()hdfs dfsadmin -allowSnapshot 路径 (开启指定目录的快照功能) ()hdfs dfsadmin ...
- 解决eclipse启动时出现“failed to load the jni shared library”
如何解决启动eclipse出现failed to load the jni shared library的问题 问题描述:启动eclipse时,出现以下弹出框 此时,即表示eclispe和jdk位数不 ...
- Hibernate之Inverse的用法
在多的一端配置Inverse设置为true,来自动管理关系
- 【题解】洛谷 P1061 Jam的计数法
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int ...
- Python对接支付宝支付自实现
Python对接支付宝支付自实现 # -*- coding: utf-8 -*- import base64 import json import urllib.parse from datetime ...
- python列表的常用操作
列表是python的基础数据类型之一 ,其他编程语言也有类似的数据类型.比如JS中的数 组, java中的数组等等. 它是以[ ]括起来, 每个元素用' , '隔开而且可以存放各种数据类型: 列表是p ...
- [WPF自定义控件]?Window(窗体)的UI元素及行为
原文:[WPF自定义控件]?Window(窗体)的UI元素及行为 1. 前言 本来打算写一篇<自定义Window>的文章,但写着写着发觉内容太多,所以还是把使用WindowChrome自定 ...