簡體   English   中英

如何在 winapi 中獲取驅動器的文件系統信息?

[英]How to get drive's filesystem information in winapi?

我有像 C:/ D:/ E:/ 這樣的磁盤字母,並且我有像 //./PhysicalDrive0、//./PhysicalDrive1 這樣的路徑。

如何獲取有關文件系統的信息?

例如:

驅動器 C:/ 是 NTFS 或更好://./PhysicalDrive0 是 NTFS

請為片段

你應該看看GetVolumeInformation() ,看看這個 API

一個例子, 在這里找到

#include <stdio.h>
#include <Windows.h>

int wmain()
{

      // + 1 is for NULL
      WCHAR volumeName[MAX_PATH + 1] = { 0 };
      WCHAR fileSystemName[MAX_PATH + 1] = { 0 };
      DWORD serialNumber = 0;
      DWORD maxComponentLen = 0;
      DWORD fileSystemFlags = 0;

      if (GetVolumeInformation(
            L"C:\\", L"\\MyServer\MyShare\"
        volumeName,
        sizeof(volumeName),
        &serialNumber,
        &maxComponentLen,
        &fileSystemFlags,
        fileSystemName,
        sizeof(fileSystemName)) == TRUE)
      {
            wprintf(L"GetVolumeInformation() should be fine!\n");
            wprintf(L"Volume Name: %s\n", volumeName);
            wprintf(L"Serial Number: %lu\n", serialNumber);
            wprintf(L"File System Name: %s\n", fileSystemName);
            wprintf(L"Max Component Length: %lu\n", maxComponentLen);
            wprintf(L"File system flags: 0X%.08X\n", fileSystemFlags);
      }
      else
      {
            wprintf(L"GetVolumeInformation() failed, error %u\n", GetLastError());
      }
      return 0;
}

output:

音量信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM