22 windows_22_windows_file 文件系统-卷
Posted 养老保险年审
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了22 windows_22_windows_file 文件系统-卷相关的知识,希望对你有一定的参考价值。
windows_22_windows_file 文件系统-卷
// windows_22_windows_file.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
void RenameDisk( )
{
SetVolumeLabel( "C:\\", "SYSTEM" );
}
void ShowSpace( LPSTR pszDrive )
{
DWORD nSecPerCluster = 0;
DWORD nBytesPerSector = 0;
DWORD nFreeClusters = 0;
DWORD nTotalClusters = 0;
GetDiskFreeSpace( pszDrive, &nSecPerCluster,
&nBytesPerSector, &nFreeClusters, &nTotalClusters );
printf( "\tnSecPerCluster:%d,nBytesPerSector:%d,nFreeClusters:%d, nTotalClusters%d\n",
nSecPerCluster, nBytesPerSector, nFreeClusters, nTotalClusters );
//获取大小
UINT64 nFreeAvailable = 0;
/*
PULARGE_INTEGER 可以用 UINT64,PULARGE_INTEGER是丙从此DWORD合成的一个结构体
UINT64 用 %I64d 输出
*/
UINT64 nTotalBytes = 0;
UINT64 nFreeBytes = 0;
GetDiskFreeSpaceEx( pszDrive, (PULARGE_INTEGER)&nFreeAvailable,
(PULARGE_INTEGER)&nTotalBytes, (PULARGE_INTEGER)&nFreeBytes );
printf( "FreeAvailable:%I64dGB Total:%I64dGB Free:%I64dGB\n",
nFreeAvailable / 1024 / 1024 / 1024, nTotalBytes / 1024 / 1024 / 1024, nFreeBytes / 1024 / 1024 / 1024 );
}
//获取磁盘信息
void ShowVolumneInfo( LPSTR pszDrive )
{
CHAR szVolumneName[256] = { 0 };
DWORD nVolumneSerial = 0;
DWORD nMaxLength = 0;
DWORD nFileSystem = 0;
CHAR szFileSystem[256] = { 0 };
//获取卷信息
GetVolumeInformation( pszDrive, szVolumneName, 256,
&nVolumneSerial, &nMaxLength, &nFileSystem,
szFileSystem, 256 );
printf( "\tName=%s Serial=%08X Length=%d FileSystem=%08X FileSystemInfo=%s\n", szVolumneName,
nVolumneSerial, nMaxLength, nFileSystem,
szFileSystem );
}
//获取盘的类型
void ShowType( LPSTR pszDrive )
{
UINT nType = GetDriveType( pszDrive );
switch (nType)
{
case DRIVE_FIXED:
printf( "%s:硬盘\n" ,pszDrive );
break;
case DRIVE_CDROM:
printf( "%s:光驱\n" ,pszDrive );
break;
case DRIVE_REMOVABLE:
printf( "%s:移动硬盘\n" ,pszDrive );
break;
default:
printf( "%s暂未识别,未识别号:%d\n", pszDrive, nType );
break;
}
}
void ShowVolumn( )
{
CHAR szText[256] = { 0 };
DWORD nDrives = GetLogicalDrives( );
printf( "nDrives:%08X\n", nDrives );
GetLogicalDriveStrings( 256, szText );
CHAR *pszTmp = szText; //定义一个临时接管指针
while (0!=pszTmp[0])
{
printf( "Drives:%s\n", pszTmp );
ShowType( pszTmp );
ShowVolumneInfo( pszTmp );
ShowSpace( pszTmp );
pszTmp = strlen( pszTmp ) + 1 + pszTmp;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
ShowVolumn( );
return 0;
}
以上是关于22 windows_22_windows_file 文件系统-卷的主要内容,如果未能解决你的问题,请参考以下文章