使用GetLogicalDriveStrings获取驱动器根路径,并使用自定义的GetDriveInfo函数获取驱动器的属性。

VS2012 + win7 x64下调试通过。

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 1024
BOOL GetDriverInfo(LPSTR szDrive);
//int WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow)
int main(void)
{
CHAR szLogicDriveStrings[BUFSIZE];
PCHAR szDrive; ZeroMemory(szLogicDriveStrings,BUFSIZE); GetLogicalDriveStrings(BUFSIZE-,szLogicDriveStrings);
szDrive = (PCHAR)szLogicDriveStrings; do
{
if(!GetDriverInfo(szDrive))
{
printf("\nGet Volume Information Error:%d",GetLastError()); }
szDrive += (lstrlen(szDrive)+);
} while (*szDrive !='\x00'); system("PAUSE");
return ; } BOOL GetDriverInfo(LPSTR szDrive)
{
UINT uDriverType;
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentlength;
DWORD dwFileSystemFlags;
CHAR szFileSystemNameBuffer[BUFSIZE];
CHAR szDriveName[MAX_PATH]; printf("\n%s\n",szDrive);
uDriverType = GetDriveType(szDrive); switch(uDriverType)
{
case DRIVE_UNKNOWN:
printf("The driver type cannot be determined!");
break;
case DRIVE_NO_ROOT_DIR:
printf("The root path is invalid,for example,no volume is mounted at the path");
break;
case DRIVE_REMOVABLE:
printf("The drive is a type that has removable media,for example:a floppy drive or removable hard disk");
break;
case DRIVE_FIXED:
printf("The drive is a type that cannot be removed, for example,a fixed hard drive");
break;
case DRIVE_REMOTE:
printf("This drive is a remote(network) drive");
break;
case DRIVE_CDROM:
printf("This drive is a CD-ROM drive.");
break;
case DRIVE_RAMDISK:
printf("This drive is a RAM disk");
break;
default:
break;
} if (!(GetVolumeInformation(
szDrive,
szDriveName,
MAX_PATH,
&dwVolumeSerialNumber,
&dwMaximumComponentlength,
&dwFileSystemFlags,
szFileSystemNameBuffer,
BUFSIZE)))
{
return FALSE; } if (!=lstrlen(szDriveName))
{
printf("\nDrive Name is %s.\n",szDriveName);
} printf("\nVolume Serial is %u.",dwVolumeSerialNumber );
printf("\nMaximum Component Length is %u.",dwMaximumComponentlength);
printf("\nSystem Type is %s.\n",szFileSystemNameBuffer); if (dwFileSystemFlags & FILE_VOLUME_QUOTAS)
{ printf("The file system supports disk Quotas.\n");
} if (dwFileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS)
{
printf("The file system does not support volume mount points.\n"); } if (dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH)
{
printf("The file system supports case-sentitive file name.\n");
} printf("...\n"); return TRUE; }

使用GetLogicalDriveStrings获取驱动器根路径的更多相关文章

  1. js获取项目根路径

    //js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost ...

  2. Java中获取项目根路径和类加载路径的7种方法

    引言 在web项目开发过程中,可能会经常遇到要获取项目根路径的情况,那接下来我就总结一下,java中获取项目根路径的7种方法,主要是通过thisClass和System,线程和request等方法. ...

  3. html 获取项目根路径

    html 获取项目根路径 function getContextPath(){ var pathName = document.location.pathname; //当前文件的绝度路径 var i ...

  4. 【spring】【spring boot】获取系统根路径,根目录,用于存储临时生成的文件在服务器上

    今日份代码: private static final String UPLOAD_TEMP_FILE_NAME = "测试商品数据.xlsx"; /** * 获取临时文件路径 * ...

  5. Spring Boot 上传文件 获取项目根路径 物理地址 resttemplate上传文件

    springboot部署之后无法获取项目目录的问题: 之前看到网上有提问在开发一个springboot的项目时,在项目部署的时候遇到一个问题:就是我将项目导出为jar包,然后用java -jar 运行 ...

  6. JAVA获取Classpath根路径的方法

    方法一: String path = Test.class.getResource("/").toString(); System.out.println("path = ...

  7. javascript 获取项目根路径

    /** * http://localhost:8088/projectName */ function getRootPath(){ //获取当前网址,如: http://localhost:8088 ...

  8. Spring下获取项目根路径--good

    Spring 在 org.springframework.web.util 包中提供了几个特殊用途的 Servlet 监听器,正确地使用它们可以完成一些特定需求的功能.比如某些第三方工具支持通过 ${ ...

  9. java-动态获取项目根路径

    ${ pageContext.request.contextPath } <hr> <a href="${ pageContext.request.contextPath ...

随机推荐

  1. listview图片错位

    借鉴这两篇文章,绝对解决,亲测有效! 国外coder的(需要FQ才能看) http://negativeprobability.blogspot.com/2011/08/lazy-loading-of ...

  2. C++ Primer--虚函数与纯虚函数的区别

    首先:强调一个概念 定义一个函数为虚函数,不代表函数为不被实现的函数. 定义他为虚函数是为了允许用基类的指针来调用子类的这个函数. 定义一个函数为纯虚函数,才代表函数没有被实现. 定义纯虚函数是为了实 ...

  3. InnoTop

    是一个系统活动报告,类似于Linux性能工具,它与Linux的top命令相仿,并参考mytop工具而设计. 它专门用后监控InnoDB性能和MySQL服务器.主要用于监控事务,死锁,外键,查询活动,复 ...

  4. 标准I/O之实现细节

    在UNIX系统中,标准I/O库最终都要调用文件I/O(read.write等).每个标准I/O流都有一个与其相关联的文件描述符,可以对一个流调用fileno函数以获得其描述符. 注意,fileno不是 ...

  5. 【转】Mac和iOS开发资源汇总—更新于2013-07-19

    小引 本文主要汇集一些苹果开发的资源,会经常更新,建议大家把这篇文章单独收藏(在浏览器中按command+D). 今天(2013年7月19日)收录了许多中文网站和博客.大家一定要去感受一下哦. 如果大 ...

  6. 从源码角度深入分析log4j配置文件使用

    log4j在日常开发中经常使用,但有时候对 配置文件应该放到什么位置有疑惑.现在我们通过从代码的角度来看待这个问题, 看完后你也许会恍然大悟哦. 开始吧. Log4j的组成及架构: Log4j由三个重 ...

  7. android自定义View之钟表诞生记

    很多筒子觉得自定义View是高手的象征,其实不然.大家觉得自定义View难很多情况下可能是因为自定义View涉及到了太多的类和API,把人搞得晕乎乎的,那么今天我们就从最简单的绘图API开始,带大家来 ...

  8. NIO学习:使用Channel、Buffer写入文件

    NIO的效率要高于标准IO,因为NIO将最耗时的IO操作(填充和提取缓冲区)转移会操作系统.NIO以块为单位传输数据,相比标准IO的以字节为单位效率要高很多. 通道和缓冲时NIO的核心对象,每个NIO ...

  9. %s 与 %0s在 verilog中的区别

    what is different between %s and %0s?(%s和%零s) %s prints the string as it is with spaces at the begin ...

  10. onitemcommand 的作用以及onitemdatabound的具体作用

    Repeater控件.DataList控件的属性:OnItemCommand 当在ItemTemplate 中所宣告的Button 或LinkButton 控件触发事件时,如果该控件CommandNa ...