函数原型:
DWORD GetLogicalDriveStringsDWORD nBufferLength,  // size of buffer
                                                           LPTSTR lpBuffer       // drive strings buffer
                                                       );
说明:
参数不多讲,需要注意函数返回存入lpBuffer空间的字符个数,不包括'\0'.
在lpBuffer内存中,驱动器的存放形式形如:

 c  : \  0 D  : \  0 E : \ 0  0  0  0  0

所以用的时候要注意指针的调整:
下面举一例:
本示例枚举本机所有逻辑驱动器,并且把驱动器分离出来:

void main()
{
CHAR szDriveBuf[MAX_PATH] = { 0 };
DWORD dwLen = GetLogicalDriveStringsA(MAX_PATH * sizeof(CHAR), szDriveBuf);
LPSTR pDrive = szDriveBuf;
while (pDrive)
{
string strDriver = pDrive;
pDrive += 4; //这里就要注意了,如果不懂就看看上面的那个内存图
}
}

Windows API 第17篇 GetLogicalDriveStrings 获取本机所有逻辑驱动器,以根目录的形式表示的更多相关文章

  1. Windows API 第16篇 GetLogicalDrivers 获取驱动器位掩码

    函数原型:DWORD GetLogicalDrives(VOID);The GetLogicalDrives function retrieves a bitmask representing the ...

  2. Windows API 第15篇 GetVolumeInformation 获取磁盘卷(驱动器)信息

    先看定义:BOOL GetVolumeInformation(    [IN]  LPCTSTR lpRootPathName,           // root directory  卷所在的根目 ...

  3. windows API 第22篇 WTSGetActiveConsoleSessionId

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

  4. Windows API 第六篇 GetLocalTime

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

  5. Windows API 第三篇

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

  6. Windows API 第20篇 GetVolumeNameForVolumeMountPoint

    函数原型: BOOL GetVolumeNameForVolumeMountPoint(                                                        ...

  7. windows API 第13篇 MoveFileEx

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

  8. Windows API 第四篇 文件操作

    创建或打开文件(也可用于打开管道,油槽,硬件设备等): HANDLE CreateFile( LPCTSTR lpFileName, // file name DWORD dwDesiredAcces ...

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

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

随机推荐

  1. xampp只允许本地访问,禁止远程访问

    远程访问phpmyadmin的时候出现错误 New XAMPP security concept: Access to the requested object is only available f ...

  2. php 扫描url死链接 \033[31m ANSI Linux终端输出带颜色

    * 从Packagist上搜索需要的包 https://packagist.org/ * 通过composer下载依赖包 composer require guzzlehttp/guzzlecompo ...

  3. echarts 默认柱状图每根柱子显示不同颜色(随机显示和定制显示)

    series: [{ name: '请求数', type: 'bar', //barGap: 60, barWidth: 140,//柱图宽度 //stack: 'sum',//堆叠效果 itemSt ...

  4. C#实现语音

    .net 4.0开始 Type type = Type.GetTypeFromProgID("SAPI.SpVoice"); dynamic spVoice = Activator ...

  5. PAT甲级——A1113 Integer Set Partition

    Given a set of N (>) positive integers, you are supposed to partition them into two disjoint sets ...

  6. vue-router路由跳转判断用户是否存在

    router.beforeEach((to, from, next) => { //console.log("to:", (to)); //console.log(" ...

  7. shell脚本练习01

    ######################################################################### # File Name: 4.5.sh # Auth ...

  8. vue 返回上一页

    参考:https://www.cnblogs.com/chenguiya/p/9118265.html 注:需为history模式 方法一: @click="back" back( ...

  9. LeetCode 21. 合并两个有序链表(Python)

    题目: 将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1->2->4, 1->3->4 输出:1->1-&g ...

  10. 转:浅析C++中的this指针

    原文出处:http://blog.csdn.net/starlee/article/details/2062586 有下面的一个简单的类: class CNullPointCall { public: ...