使用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 ...
随机推荐
- C链表反转(时间复杂度O(n))
面试的时候经常会出现的问题,现在都做一遍,回忆一下,练练手. 这个题目需要注意两点: 1.head->next 要先设置为NULL ,否则反转后,它还是指向之前的next节点 2.需要有一个tm ...
- 更改 Tomcat 日志路径
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- 【转】使用VisualSVN Server搭建SVN服务器
http://blog.csdn.net/han_yankun2009/article/details/7856992 使用 VisualSVN Server来实现主要的 SVN功能则要比使用原始的 ...
- 打造强大的BaseModel(2):让Model实现自动映射,将字典转化成Model
打造强大的BaseModel(1):让Model自我描述 这篇文章将讲述Model一项更高级也最常用的功能,让Model实现自动映射–将字典转化成Model(所有代码全由Swift实现) 将JSON转 ...
- jquery动态添加列表后样式失效解决方式
最近在做一个通讯录,使用jquery mobile方式来做,在动态添加列表后,listview原有的样式失效,折腾一会,找出解决办法.代码如下. <%@ page language=" ...
- 解决Ubuntu下sublime中不能输入中文的问题
解决Ubuntu下sublime中不能输入中文的问题 Ubuntu下安装sublime后,不能输入中文,而在其他软件中能正常输入,这是sublime的bug,解决方案是在通过shell在每次运行sub ...
- Ubuntu 14.04 忘记用户密码(备忘)
参考文章地址:www.linuxidc.com/Linux/2013-11/92236.htm 重启电脑 开机就会进入一个Grub引导页面,选择 "Ubuntu 高级选项"之后,按 ...
- 使用canvas制作在线画板
canvas绘图的强大功能,让人前仆后继的去研究它.代码全部加起来不足百行.还用到了h5中的<input type="color"/>和<input type=& ...
- c# switch case语句
switch是一个控制语句,用于选择一个要执行的语句块. 一个switch语句包括一个或多个执行的语句块.每个语句块包括一个或多个case标签,case后接要执行的语句. 如下面的代码 Codeint ...
- Unity3D 之3D游戏入门Hello world(一)
这几天开始玩Unity3D 有关3D的内容了,去年开始玩过一段时间的2D制作,不过因为年初找工作,所以放了一段时间, 现在再捡起来发现忘的已经差不多了,只能再从头开始,所以就从3D开始算了.下面是3D ...