使用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 ...
随机推荐
- 解决TortoiseCVS中文乱码
解决TortoiseCVS中文乱码必备,解决方法: 第一:卸载和TortoiseCVS安装一起安装的CVSNT. 第二:安装本版本CVSNT. CVSNT下载地址:http://down.51cto. ...
- java发送带附件的邮件
/** * java发送带附件的邮件 * 周枫 * 2013.8.10 */ package com.dsideal.Util; import javax.mail.*; import javax.m ...
- windows 7 64位 安装oracle 11g R2
1.下载Oracle 11g R2 for Windows的版本 下载地址: http://www.oracle.com/technetwork/database/enterprise-edition ...
- linux shell执行方式
linux shell执行有两种方式 shell脚本以#!/bin/bash开头,执行shell时先检查首行,在内部以下列方式执行: $/bin/bash script.sh 1. 使用sh执行. $ ...
- hdu2565java
放大的X Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissio ...
- Android开发之IPC进程间通信-AIDL介绍及实例解析
一.IPC进程间通信 IPC是进程间通信方法的统称,Linux IPC包括以下方法,Android的进程间通信主要采用是哪些方法呢? 1. 管道(Pipe)及有名管道(named pipe):管道可用 ...
- mac 终端中添加tree命令显示文件目录结构
在Ubuntu下,通过 sudo apt-get install tree 可以使用tree命令,显示文件目录列表,如图所示: 在mac OS X系统下怎么使用呢? 在终端输入: cd $home ...
- JVM笔记6:JVM类加载机制
虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验.转换解析.初始化,最终形成可以被虚拟机直接使用的Java类型,这就是虚拟机的类加载机制 从类被加载到虚拟机内存中开始,到卸载出内存为止 ...
- hdu 1570 AC
A C Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- 【转】小议Bug敏感度---Bug敏感度的故事(一)
在测试圈中,相信大家对“Bug敏感度”这一词并不陌生,但是Bug敏感度具体是指什么呢,本文对此关键词进行解读的基础上,对其与软件质量的关系,影响的关键因素,如何提高测试人员的bug敏感度进行分享.(- ...