如何知道某个磁盘的格式(是FAT32还是NTFS) [英] How to know a certain disk's format(is FAT32 or NTFS)

查看:128
本文介绍了如何知道某个磁盘的格式(是FAT32还是NTFS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows,C ++,MFC下编程 如何通过"c:\"之类的路径知道磁盘的格式. Windows是否提供此类API?

I am programing under windows, c++, mfc How can I know disk's format by path such as "c:\". Does windows provide such APIs?

推荐答案

您正在寻找Win32API函数:: GetVolumeInformation.

The Win32API function ::GetVolumeInformation is what you are looking for.

从MSDN:

GetVolumeInformation函数

BOOL WINAPI GetVolumeInformation(
    __in_opt   LPCTSTR lpRootPathName,
    __out      LPTSTR lpVolumeNameBuffer,
    __in       DWORD nVolumeNameSize,
    __out_opt  LPDWORD lpVolumeSerialNumber,
    __out_opt  LPDWORD lpMaximumComponentLength,
    __out_opt  LPDWORD lpFileSystemFlags,
    __out      LPTSTR lpFileSystemNameBuffer, // Here
    __in       DWORD nFileSystemNameSize
);

示例:

TCHAR fs [MAX_PATH+1];
::GetVolumeInformation(_T("C:\\"), NULL, 0, NULL, NULL, NULL, &fs, MAX_PATH+1);
// Result is in (TCHAR*) fs

这篇关于如何知道某个磁盘的格式(是FAT32还是NTFS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆