#include
<
stdafx.h
>
#include < Windows.h >
#include < iostream >
#include < string >
// using namespace std;
void findAllDrivers( void )
... {
std::cout << "All Drivers are listed below You can type one of them to see it's ID: "
<< std::endl;
DWORD dwNumBytesForDriverStrings;
HANDLE hHeap;
wchar_t* lp;
dwNumBytesForDriverStrings = GetLogicalDriveStrings(0,NULL)*sizeof(TCHAR);
if(dwNumBytesForDriverStrings !=0)
...{
hHeap = GetProcessHeap();
lp = (wchar_t*)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,dwNumBytesForDriverStrings);
GetLogicalDriveStrings(HeapSize(hHeap,0,lp),lp);
while(*lp != 0)
...{
std::wcout << lp << std::endl;
lp = wcschr(lp,0) + 1;
}
}
else
std::cout << "Can't Use The Function GetLogicalDriveStrings!" << std::endl;
}
int main( void )
... {
findAllDrivers();
std::cout << "Type a RootPathName of the Drivers(format X:/) >: " << std::flush;
std::wstring strRootPath;
while(std::wcin >> strRootPath)
...{
LPCTSTR lpRootPath = strRootPath.c_str();
LPTSTR lpVolumeNameBuffer = new wchar_t[12];
DWORD nVolumeNameSize = 12;
DWORD VolumeSerialNumber;
DWORD MaxinumComponentLength;
DWORD FileSystemFlags;
LPTSTR lpFileSystemNameBuffer = new wchar_t[10];
DWORD nFileSystemNameSize = 10;
GetVolumeInformation(lpRootPath,lpVolumeNameBuffer,nVolumeNameSize,
&VolumeSerialNumber,&MaxinumComponentLength,&FileSystemFlags,
lpFileSystemNameBuffer,nFileSystemNameSize);
std::wcout << "驱动器 " << strRootPath << " 的序列号为: "
<< VolumeSerialNumber << std::endl;
std::wcout << "File System Type: " << lpFileSystemNameBuffer << std::endl;
std::cout << "Type a RootPathName of the Drivers(format X:/) >: " << std::flush;
}
}
#include < Windows.h >
#include < iostream >
#include < string >
// using namespace std;
void findAllDrivers( void )
... {
std::cout << "All Drivers are listed below You can type one of them to see it's ID: "
<< std::endl;
DWORD dwNumBytesForDriverStrings;
HANDLE hHeap;
wchar_t* lp;
dwNumBytesForDriverStrings = GetLogicalDriveStrings(0,NULL)*sizeof(TCHAR);
if(dwNumBytesForDriverStrings !=0)
...{
hHeap = GetProcessHeap();
lp = (wchar_t*)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,dwNumBytesForDriverStrings);
GetLogicalDriveStrings(HeapSize(hHeap,0,lp),lp);
while(*lp != 0)
...{
std::wcout << lp << std::endl;
lp = wcschr(lp,0) + 1;
}
}
else
std::cout << "Can't Use The Function GetLogicalDriveStrings!" << std::endl;
}
int main( void )
... {
findAllDrivers();
std::cout << "Type a RootPathName of the Drivers(format X:/) >: " << std::flush;
std::wstring strRootPath;
while(std::wcin >> strRootPath)
...{
LPCTSTR lpRootPath = strRootPath.c_str();
LPTSTR lpVolumeNameBuffer = new wchar_t[12];
DWORD nVolumeNameSize = 12;
DWORD VolumeSerialNumber;
DWORD MaxinumComponentLength;
DWORD FileSystemFlags;
LPTSTR lpFileSystemNameBuffer = new wchar_t[10];
DWORD nFileSystemNameSize = 10;
GetVolumeInformation(lpRootPath,lpVolumeNameBuffer,nVolumeNameSize,
&VolumeSerialNumber,&MaxinumComponentLength,&FileSystemFlags,
lpFileSystemNameBuffer,nFileSystemNameSize);
std::wcout << "驱动器 " << strRootPath << " 的序列号为: "
<< VolumeSerialNumber << std::endl;
std::wcout << "File System Type: " << lpFileSystemNameBuffer << std::endl;
std::cout << "Type a RootPathName of the Drivers(format X:/) >: " << std::flush;
}
}