使用GetLogicalDriveStrings获取驱动器根路径
使用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获取驱动器根路径的更多相关文章
- js获取项目根路径
//js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost ...
- Java中获取项目根路径和类加载路径的7种方法
引言 在web项目开发过程中,可能会经常遇到要获取项目根路径的情况,那接下来我就总结一下,java中获取项目根路径的7种方法,主要是通过thisClass和System,线程和request等方法. ...
- html 获取项目根路径
html 获取项目根路径 function getContextPath(){ var pathName = document.location.pathname; //当前文件的绝度路径 var i ...
- 【spring】【spring boot】获取系统根路径,根目录,用于存储临时生成的文件在服务器上
今日份代码: private static final String UPLOAD_TEMP_FILE_NAME = "测试商品数据.xlsx"; /** * 获取临时文件路径 * ...
- Spring Boot 上传文件 获取项目根路径 物理地址 resttemplate上传文件
springboot部署之后无法获取项目目录的问题: 之前看到网上有提问在开发一个springboot的项目时,在项目部署的时候遇到一个问题:就是我将项目导出为jar包,然后用java -jar 运行 ...
- JAVA获取Classpath根路径的方法
方法一: String path = Test.class.getResource("/").toString(); System.out.println("path = ...
- javascript 获取项目根路径
/** * http://localhost:8088/projectName */ function getRootPath(){ //获取当前网址,如: http://localhost:8088 ...
- Spring下获取项目根路径--good
Spring 在 org.springframework.web.util 包中提供了几个特殊用途的 Servlet 监听器,正确地使用它们可以完成一些特定需求的功能.比如某些第三方工具支持通过 ${ ...
- java-动态获取项目根路径
${ pageContext.request.contextPath } <hr> <a href="${ pageContext.request.contextPath ...
随机推荐
- android109 结构体,联合体,枚举,自定义
#include <stdio.h> #include <stdlib.h> void study(){ printf("吃饭睡觉打李志\n"); } // ...
- careercup-递归和动态规划 9.4
9.4 编写一个方法,返回某集合的所有子集. 类似leetcode:Subsets 解法: 解决这个问题之前,我们先要对时间和空间复杂度有个合理的评估.一个集合会有多少子集?我们可以这么计算,生成了一 ...
- careercup-树与图 4.3
4.3 给定一个有序整数数组,元素各不相同按升序排列,编写一个算法,创建一棵高度最小的二叉查找树. 解答 想要使构建出来的二叉树高度最小,那么对于任意结点, 它的左子树和右子树的结点数量应该相当.比如 ...
- cocos2dx下最大纹理大小取决于平台
原文:http://www.cocos2d-x.org/wiki/Max_size_of_textures_in_cocos2d-x_depends_on_each_platform 在理论上,coc ...
- 嵌入式Linux-GNU Make 使用手册(中译版)
GNU Make 使用手册(中译版) 翻译:于凤昌 译者注:本人在阅读Linux源代码过程中发现如果要全面了解Linux的结构.理解Linux的编程总体设计及思想必须首先全部读通Linux源代码中各级 ...
- 关于IB_DESIGNABLE / IBInspectable的那些事
前言 IB_DESIGNABLE / IBInspectable 这两个关键字是在WWDC 2014年”What’s New in Interface Builder”这个Session里面,用Swi ...
- 第七篇:web之前端之ajax
前端之ajax 前端之ajax 本节内容 ajax介绍 原生js实现ajax jquery实现ajax json 跨域请求 1. ajax介绍 AJAX(Asynchronous Javascri ...
- (转)了解了这些才能开始发挥jQuery的威力
原文地址:http://www.cnblogs.com/dolphinX/p/3347677.html 由于当前jQuery如此的如雷贯耳,相信不用介绍什么是jQuery了,公司代码中广泛应用了jQu ...
- jquery click事件的可选参数data的作用
$("#ID").click({x:"value"},function (e) { alert(e.data.x); });
- 介绍SmartUpload很好的网站
附带链接:http://www.cnblogs.com/elleniou/archive/2012/09/24/2700583.html