GetLogicalDrives,GetLogicalDriveStrings,GetDri...
2019独角兽企业重金招聘Python工程师标准>>>
#include "stdafx.h"
#include <tchar.h>
#include <Windows.h>
#include <bitset>
#include <iostream>
#ifdef _UNICODE
#define tcout wcout
#else
#define tcout cout
#endif
int _tmain(int argc, _TCHAR* argv[])
{ TCHAR tables[][4] = { _T("A://"), _T("B://"), _T("C://"), _T("D://"), _T("E://"), _T("F://"), _T("G://"), _T("H://") }; std::bitset<32> bitMap(::GetLogicalDrives()); for (size_t i = 0; i < bitMap.size() && i < sizeof(tables) / 4; i++) { if (bitMap[i]) { std::tcout << tables[i] << std::endl; } } std::cout << _T("--------------------------------------------") << std::endl; TCHAR pszBuffer[MAX_PATH]; DWORD nCnt = ::GetLogicalDriveStrings(MAX_PATH, pszBuffer); TCHAR* p; if (nCnt > 0) { p = pszBuffer; while (*p != _T('/0')) { std::tcout << p << std::endl; p = p + _tcslen(p) + 1; } } /*TCHAR szBuffer[MAX_PATH]; HANDLE handle = ::FindFirstVolume(szBuffer, MAX_PATH); if (handle != NULL) { do{ std::tcout << szBuffer << std::endl; }while (::FindNextVolume(handle, szBuffer, MAX_PATH)); ::FindVolumeClose(handle); }*/ for (size_t i = 0; i < sizeof(tables) / 4; i++) { UINT nRet = ::GetDriveType(tables[i]); //#define DRIVE_UNKNOWN 0 //#define DRIVE_NO_ROOT_DIR 1 //#define DRIVE_REMOVABLE 2 //#define DRIVE_FIXED 3 //#define DRIVE_REMOTE 4 //#define DRIVE_CDROM 5 //#define DRIVE_RAMDISK 6 switch (nRet) { case DRIVE_UNKNOWN: std::tcout << tables[i] << _T("DRIVE_UNKNOWN") << std::endl; break; case DRIVE_NO_ROOT_DIR: std::tcout << tables[i] << _T("DRIVE_NO_ROOT_DIR") << std::endl; break; case DRIVE_REMOVABLE: std::tcout << tables[i] << _T("DRIVE_REMOVABLE") << std::endl; break; case DRIVE_FIXED: std::tcout << tables[i] << _T("DRIVE_FIXED") << std::endl; break; case DRIVE_REMOTE: std::tcout << tables[i] << _T("DRIVE_REMOTE") << std::endl; break; case DRIVE_CDROM: std::tcout << tables[i] << _T("DRIVE_CDROM") << std::endl; break; case DRIVE_RAMDISK: std::tcout << tables[i] << _T("DRIVE_RAMDISK") << std::endl; break; } } return 0;
}
转载于:https://my.oschina.net/ypimgt/blog/68478
GetLogicalDrives,GetLogicalDriveStrings,GetDri...相关推荐
- 常用WinAPI函数整理
之前的博客写了很多关于Windows编程的内容,在Windows环境下的黑客必须熟练掌握底层API编程.为了使读者对黑客常用的Windows API有个更全面的了解以及方便日后使用API方法的查询,特 ...
- Windows API Reference for C#, VB.NET
不错的.net 下用API的参考站点 地址在:http://www.webtropy.com/articles/Win32-API-DllImport-art9.asp 下面摘抄分类,便于大家直接就拿 ...
- GetLogicalDriveStringS获取驱动器根路径
GetLogicalDriveStringS获取驱动器根路径 #include <windows.h> #include <stdlib.h> #include <std ...
- GetLogicalDrives GetDriveType GetVolumeInformation和FindVolumeClose
文章目录 GetLogicalDrives 功能 返回值 代码实现: GetDriveType 函数声明 函数功能 第一个参数: 返回值 GetVolumeInformation 函数声明 函数功能 ...
- GetLogicalDriveStrings FindFirstVolume和FindNextVolume
文章目录 GetLogicalDriveStrings 函数功能: 函数原型: 第一个参数 第二个参数 返回值: 代码实现 FindFirstVolume 函数功能 第一个参数 第二个参数 返回值 F ...
- WinAPI: GetLogicalDrives - 判断系统中存在的逻辑驱动器
//声明: GetLogicalDrives: DWORD; {无参数}//返回值: 返回值的二进制右边第一位为 1 表示驱动器 A: 存在; 返回值的二进制右边第二位为 1 表示驱动器 B: 存在. ...
- Windows API 逐个逐个学MessageBox(5) 遍历驱动器并获取驱动器属性 GetLogicalDriveStrings、GetDriveTypeA...
首先还是贴代码 VC++ Code: /* *************************************<精通Windows API> * 示例代码* GetVolumeIn ...
- Windows API ——GetLogicalDriveStrings——获取逻辑驱动器
1 TCHAR buffer[MAX_PATH]; 2 DWORD dwVal=::GetLogicalDriveStrings(MAX_PATH,buffer); 3 4 CString str; ...
- Windows API函数大全
1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同 ...
- win32 wmi编程获取系统信息
//GetSysInfo.h#pragma once#include <afxtempl.h>class GetSysInfo { public:GetSysInfo(void);~Get ...
最新文章
- Linux学习之三-Linux系统的一些重要配置文件
- linux中ctrl+z和ctrl+c的区别
- 中国出版业,九死一生
- 数据算法:推荐系统的实践与思考(下)【转】
- 工具:分享IntelliJ IDEA 5条调试技巧,太实用了!
- String str=“i“与 String str=new String(“i”)一样吗?
- 结构体内存对齐的原则及原理
- Atitit hibernste5 注解方式开发总结 目录 1. 映入hb5的jar 建立项目	1 1.1. 建表tab1 ,这里使用了sqlite数据库	1 1.2. 建立映射实体类tab1
- php houdini,houdini中文翻译.pdf
- Strategy模式简述
- Access数据库偏移注入
- 去处word红色波浪线
- 【Practical】产生不大于N的连续素数序列 —— 埃拉托色尼筛法
- python 自动化微信小程序_干货 | 微信小程序自动化测试最佳实践(附 Python 源码)...
- JDK 8 JVM性能优化
- 验证集到底有什么作用
- 淘宝网 286亿海量图片存储与处理架构
- MPC5748G开发笔记-----S32DS提示The target may have entered reset escalation
- 浅析客户端渲染(CSR)与服务端渲染(SSR)
- 区块链丨拒绝虚假信息,优化你的网络社交生活
热门文章
- 也谈谈让好马吃回头草
- Wireshark实战分析之ARP协议(一)
- linux网络分析之回环网卡
- linux内核分析与应用 -- 内存管理(上)
- 虚拟机里Ubuntu编译内核方法
- html页面整体换算单位,通过媒体查询meta和JS转换REM单位实现100%自适应
- python将元祖设为整形_相识python --------str字符串 int整形 bool布尔值 tu元祖 set()集合 dict 字典的数据补充...
- 安装SQLserver时候报错:应用程序中发生了无法处理的异常。如果单击继续。。。。。
- html 字符串 放到webbrowser,delphi 直接将html字符串读入WebBrowser中
- centos运行jar包需要的环境_SpringBoot+Vue前后端一次打包为一个Jar包运行