获取路径所在磁盘剩余大小


quint64 get_disk_remain_space(const QString & drive_letter)
{
	LPCWSTR lpcwstrDriver = (LPCWSTR)drive_letter.utf16();

	ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes;

	if (!GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes))
	{
		qDebug() << "ERROR: Call to GetDiskFreeSpaceEx() failed.";
		return -1;
	}
	return (quint64)liTotalFreeBytes.QuadPart/ (1024 * 1024);  // 返回单位是多少M
}

 

你可能感兴趣的:(QT)