// Windows 2000以降でOK(9xではバッファは減らしましょう)
#include <windows.h>
#include <tchar.h>
#include <shlwapi.h>
BOOL IsNTFS ( const _TCHAR *pszRootPath )
{
enum
{
MY_MAX_BUFFER = 2048
};
_TCHAR szFileSystem[ MY_MAX_BUFFER ];
memset ( szFileSystem, 0, sizeof ( szFileSystem ) );
if ( 0 != GetVolumeInformation ( pszRootPath,
NULL,
0,
NULL,
NULL,
NULL,
szFileSystem,
MY_MAX_BUFFER ) )
{
_TCHAR *p = StrStrI ( szFileSystem, _TEXT ( "NTFS" ) );
if ( 0 != p )
{
return TRUE;
}
}
return FALSE;
}
int WINAPI _tWinMain ( HINSTANCE,
HINSTANCE,
_TCHAR *,
int )
{
// ドライブのルートパスを順に列挙 "C:\\<NULL>D:\\<NULL>...Z:\\<NULL><NULL>"
DWORD dwDrivesSize = GetLogicalDriveStrings ( 0, NULL );
_TCHAR *pszDrives = new _TCHAR[ dwDrivesSize + 1 ];
GetLogicalDriveStrings ( dwDrivesSize, pszDrives );
_TCHAR *p = pszDrives;
while ( '\0' != *p )
{
// そのドライブが NTFS か?
if ( IsNTFS ( p ) )
{
MessageBox ( NULL,
_TEXT ( "NTFSです" ),
p,
MB_OK );
}
else
{
MessageBox ( NULL,
_TEXT ( "NTFSではありません" ),
p,
MB_OK );
}
p += lstrlen ( p ) + 1;
}
return 0;
}
|