m_dir="";
CHAR *buf=new char[100];
char drs[26];
GetLogicalDriveStrings(50,buf);
int i=0;
while (*buf) {
drs[i]=*buf;
while(*buf!='\0')buf++;
buf++;
i++;
}
for (int j=0;j<i;j++)
{
CString path;
path.Format("\\\\.\\%c:",drs[j]);
HANDLE hdev= CreateFile(path,GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
OPEN_EXISTING,
0,0);
int er=GetLastError();
VOLUME_DISK_EXTENTS st={0};
DWORD outsize;
DeviceIoControl(hdev,
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
NULL,0,
&st,sizeof(VOLUME_DISK_EXTENTS),&outsize,NULL);
CString num;
num.Format("%c [%d] %d\r\n",drs[j],st.Extents[0].DiskNumber,st.NumberOfDiskExtents);
m_dir=m_dir+num;
}
UpdateData(false);
CHAR *buf=new char[100];
char drs[26];
GetLogicalDriveStrings(50,buf);
int i=0;
while (*buf) {
drs[i]=*buf;
while(*buf!='\0')buf++;
buf++;
i++;
}
for (int j=0;j<i;j++)
{
CString path;
path.Format("\\\\.\\%c:",drs[j]);
HANDLE hdev= CreateFile(path,GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
OPEN_EXISTING,
0,0);
int er=GetLastError();
VOLUME_DISK_EXTENTS st={0};
DWORD outsize;
DeviceIoControl(hdev,
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
NULL,0,
&st,sizeof(VOLUME_DISK_EXTENTS),&outsize,NULL);
CString num;
num.Format("%c [%d] %d\r\n",drs[j],st.Extents[0].DiskNumber,st.NumberOfDiskExtents);
m_dir=m_dir+num;
}
UpdateData(false);
https://files.cnblogs.com/ahuo/DriversInfo.rar