如何显示程序所在分区的磁盘信息
本帖最后由 lianrouwupan 于 2013-12-25 21:41:16 编辑
void __fastcall TForm1::Button8Click(TObject *Sender)
{
ULARGE_INTEGER FreeSpaceToCall,TotalSpace,FreeSpace;
::GetDiskFreeSpaceEx("D:",&FreeSpaceToCall,&TotalSpace,&FreeSpace);
ShowMessage("程序所在分区总空间(MB):"+AnsiString(TotalSpace.QuadPart/1024/1024)+"\n"+"剩余空间(MB):"+AnsiString(FreeSpace.QuadPart/1024/1024));
}
::GetDiskFreeSpaceEx(String().sprintf(TEXT("%s:"),
ExtractFileDrive(ParamStr(0))).c_str(),
&FreeSpaceToCall, &TotalSpace, &FreeSpace);
void __fastcall TForm1::Button8Click(TObject *Sender)
{
ULARGE_INTEGER FreeSpaceToCall,TotalSpace,FreeSpace;
AnsiString drv = ExtractFileDrive(Application->ExeName);
::GetDiskFreeSpaceEx(drv.c_str(),&FreeSpaceToCall,&TotalSpace,&FreeSpace);
ShowMessage("程序所在分区:" + drv + "\n总空间(MB):"
+ AnsiString(TotalSpace.QuadPart/1024/1024) + "\n"
+"剩余空间(MB):" + AnsiString(FreeSpace.QuadPart/1024/1024));
}