C++ 通过WIN32 API 获取逻辑磁盘详细信息

2014-11-24 13:16:31 · 作者: · 浏览: 7

众所周知,在微软的操作系统下编写应用程序,最主要的还是通过windows所提供的api函数来实现各种操作的,这些函数通常是可以直接使用的,只要包含windows.h这个头文件, 下载源文件

今天我们主要介绍的是几个常用的api函数,通过它我们可以获取用户磁盘的相关信息。

其主要函数原型说明如下:

1.获取系统中逻辑驱动器的数量

The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.

DWORD GetLogicalDrives(void);
   

2.获取所有驱动器字符串信息

The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system.

DWORD GetLogicalDriveStrings(
   
  DWORD nBufferLength,
    
  LPTSTR lpBuffer
     
);
   

3.获取驱动器类型

The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.

UINT GetDriveType(
   
  LPCTSTR lpRootPathName
     
);
   

<script type="text/java script">BAIDU_CLB_fillSlot("771048");
点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
分享到: 更多
<script type="text/java script" id="bdshare_js" data="type=tools&uid=12732"> <script type="text/java script" id="bdshell_js"> <script type="text/java script"> var bds_config = {'snsKey':{'tsina':'2386826374','tqq':'5e544a8fdea646c5a5f3967871346eb8'}}; document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js cdnversion=" + Math.ceil(new Date()/3600000)