22 windows_22_windows_file 文件系统-卷

Posted 养老保险年审

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了22 windows_22_windows_file 文件系统-卷相关的知识,希望对你有一定的参考价值。

windows_22_windows_file 文件系统-卷


  1. // windows_22_windows_file.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. #include <windows.h>
  5. void RenameDisk( )
  6. {
  7. SetVolumeLabel( "C:\\", "SYSTEM" );
  8. }
  9. void ShowSpace( LPSTR pszDrive )
  10. {
  11. DWORD nSecPerCluster = 0;
  12. DWORD nBytesPerSector = 0;
  13. DWORD nFreeClusters = 0;
  14. DWORD nTotalClusters = 0;
  15. GetDiskFreeSpace( pszDrive, &nSecPerCluster,
  16. &nBytesPerSector, &nFreeClusters, &nTotalClusters );
  17. printf( "\tnSecPerCluster:%d,nBytesPerSector:%d,nFreeClusters:%d, nTotalClusters%d\n",
  18. nSecPerCluster, nBytesPerSector, nFreeClusters, nTotalClusters );
  19. //获取大小
  20. UINT64 nFreeAvailable = 0;
  21. /*
  22. PULARGE_INTEGER 可以用 UINT64,PULARGE_INTEGER是丙从此DWORD合成的一个结构体
  23. UINT64 用 %I64d 输出
  24. */
  25. UINT64 nTotalBytes = 0;
  26. UINT64 nFreeBytes = 0;
  27. GetDiskFreeSpaceEx( pszDrive, (PULARGE_INTEGER)&nFreeAvailable,
  28. (PULARGE_INTEGER)&nTotalBytes, (PULARGE_INTEGER)&nFreeBytes );
  29. printf( "FreeAvailable:%I64dGB Total:%I64dGB Free:%I64dGB\n",
  30. nFreeAvailable / 1024 / 1024 / 1024, nTotalBytes / 1024 / 1024 / 1024, nFreeBytes / 1024 / 1024 / 1024 );
  31. }
  32. //获取磁盘信息
  33. void ShowVolumneInfo( LPSTR pszDrive )
  34. {
  35. CHAR szVolumneName[256] = { 0 };
  36. DWORD nVolumneSerial = 0;
  37. DWORD nMaxLength = 0;
  38. DWORD nFileSystem = 0;
  39. CHAR szFileSystem[256] = { 0 };
  40. //获取卷信息
  41. GetVolumeInformation( pszDrive, szVolumneName, 256,
  42. &nVolumneSerial, &nMaxLength, &nFileSystem,
  43. szFileSystem, 256 );
  44. printf( "\tName=%s Serial=%08X Length=%d FileSystem=%08X FileSystemInfo=%s\n", szVolumneName,
  45. nVolumneSerial, nMaxLength, nFileSystem,
  46. szFileSystem );
  47. }
  48. //获取盘的类型
  49. void ShowType( LPSTR pszDrive )
  50. {
  51. UINT nType = GetDriveType( pszDrive );
  52. switch (nType)
  53. {
  54. case DRIVE_FIXED:
  55. printf( "%s:硬盘\n" ,pszDrive );
  56. break;
  57. case DRIVE_CDROM:
  58. printf( "%s:光驱\n" ,pszDrive );
  59. break;
  60. case DRIVE_REMOVABLE:
  61. printf( "%s:移动硬盘\n" ,pszDrive );
  62. break;
  63. default:
  64. printf( "%s暂未识别,未识别号:%d\n", pszDrive, nType );
  65. break;
  66. }
  67. }
  68. void ShowVolumn( )
  69. {
  70. CHAR szText[256] = { 0 };
  71. DWORD nDrives = GetLogicalDrives( );
  72. printf( "nDrives:%08X\n", nDrives );
  73. GetLogicalDriveStrings( 256, szText );
  74. CHAR *pszTmp = szText; //定义一个临时接管指针
  75. while (0!=pszTmp[0])
  76. {
  77. printf( "Drives:%s\n", pszTmp );
  78. ShowType( pszTmp );
  79. ShowVolumneInfo( pszTmp );
  80. ShowSpace( pszTmp );
  81. pszTmp = strlen( pszTmp ) + 1 + pszTmp;
  82. }
  83. }
  84. int _tmain(int argc, _TCHAR* argv[])
  85. {
  86. ShowVolumn( );
  87. return 0;
  88. }





以上是关于22 windows_22_windows_file 文件系统-卷的主要内容,如果未能解决你的问题,请参考以下文章

23 windows_22_windows_Directory 文件系统 - 目录

《自拍教程22》wget_文件下载工具

请教windows下,安装sqlite3的方法

22.dll调用技术

22_IO_第22天(File递归)_讲义

极客时间每日一课