2010-06-24 15 views

回答

2
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, 
    __in  DWORD nFileSystemNameSize 
); 

http://msdn.microsoft.com/en-us/library/aa364993(v=VS.85).aspx

傳遞體積根路徑(如「C:\」)中,獲得了大量的信息(包括卷名,也稱爲卷標)出來。

可用自Windows 2000

0

您可以從該代碼得到它:

BOOL WINAPI GetVolumeNameForVolumeMountPoint(
    __in LPCTSTR lpszVolumeMountPoint, 
    __out LPTSTR lpszVolumeName, 
    __in DWORD cchBufferLength 
); 

更多參考Click here

2

使用下面的代碼片段:

TCHAR volumeName[MAX_PATH + 1] = { 0 }; 
TCHAR fileSystemName[MAX_PATH + 1] = { 0 }; 
DWORD serialNumber = 0; 
DWORD maxComponentLen = 0; 
DWORD fileSystemFlags = 0; 

if (GetVolumeInformation(
    _T("C:\\"), 
    volumeName, 
    ARRAYSIZE(volumeName), 
    &serialNumber, 
    &maxComponentLen, 
    &fileSystemFlags, 
    fileSystemName, 
    ARRAYSIZE(fileSystemName))) 
{ 
_tprintf(_T("Volume Name: %s\n"), volumeName); 
_tprintf(_T("Serial Number: %lu\n"), serialNumber); 
_tprintf(_T("File System Name: %s\n"), fileSystemName); 
_tprintf(_T("Max Component Length: %lu\n"), maxComponentLen); 
} 

在我係統的輸出是:

Volume Name: Zion 
Serial Number: 112749257 
File System Name: NTFS 
Max Component Length: 255