От Здесь :
Это дает вам диски, которые используются, просто уберите их из остальной части алфавита AZ
////////////////////////////////////////////////////////////////
// MSDN Magazine -- April 2002
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0. Set tabsize = 3 in your editor.
// Runs in Windows XP and probably Windows 2000 too.
//
#include "stdafx.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
using namespace std; // for string class
//////////////////
// This mini-table maps GetDriveType codes to human-readable string
//
struct {
UINT type; // return code from GetDriveType
LPCSTR name; // ascii name
} DriveTypeFlags [] = {
{ DRIVE_UNKNOWN, "Unknown" },
{ DRIVE_NO_ROOT_DIR, "Invalid path" },
{ DRIVE_REMOVABLE, "Removable" },
{ DRIVE_FIXED, "Fixed" },
{ DRIVE_REMOTE, "Network drive" },
{ DRIVE_CDROM, "CD-ROM" },
{ DRIVE_RAMDISK, "RAM disk" },
{ 0, NULL},
};
//////////////////
// Standard tmain for MFC ListDrives app
//
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
cerr << _T("Fatal Error: MFC initialization failed") << endl;
return -1;
}
// Get logical drive strings-- a:\b:\c:\... etc.
// Could also use GetLogicalDrives to get in the form of a bitmap instead
// of character string.
//
TCHAR buf[100];
DWORD len = GetLogicalDriveStrings(sizeof(buf)/sizeof(TCHAR),buf);
// Display information about each drive.
//
string msg = "Logical Drives:\n"; // STL string
for (TCHAR* s=buf; *s; s+=_tcslen(s)+1) {
LPCTSTR sDrivePath = s;
msg += sDrivePath;
msg += " ";
// GetDriveType gets one of the enum values DRIVE_UNKNOWN, etc.
//
UINT uDriveType = GetDriveType(sDrivePath);
// Find drive type in table. I do a table lookup here to be extra
// cautious, but since the uDriveType values are sequential, i could've
// used DriveTypeFlags[uDriveType] instead of linear lookup. In
// practice you would usually perform some check like
//
// if (uDriveType & DEVICE_CDROM) {
// ...
// }
//
for (int i=0; DriveTypeFlags[i].name; i++) {
if (uDriveType == DriveTypeFlags[i].type) {
msg += DriveTypeFlags[i].name;
break;
}
}
msg += '\n';
}
cout << msg.c_str();
return 0;
}