//获取磁盘容量
void CFileManagerDlg::OnMENUrom()
{
// TODO: Add your command handler code here
char w_rom[BUF_SIZE];
char r_rom[BUF_SIZE];
int ret = 0;
DWORD sum = 0, use = 0;
w_rom[0] = 0x20;
CString a,b;
usb_bulk_write(dev,EP_OUT,w_rom,1,5000);
ret = usb_bulk_read(dev,EP_IN,r_rom,sizeof(r_rom),5000);
if((r_rom[0]==0x20) && (r_rom[1]=='G'))
{
sum = r_rom[2] + r_rom[3]*256 + r_rom[4]*256*256 + r_rom[5]*256*256*256;
use = r_rom[6] + r_rom[7]*256 + r_rom[8]*256*256 + r_rom[9]*256*256*256;
a.Format("%u",sum);
b.Format("%u",use);
MessageBox("磁盘总容量"+a+"已用磁盘容量"+b);
}
else
{
MessageBox("获取磁盘容量失败!");
}
}
转载于:https://www.cnblogs.com/nevermorelsf/p/5784683.html