如题,有没有什么函数能得到物理硬盘的剩余大小?
GetDiskFreeSpaceEx只能得到具体分区的剩余容量情况。
我现在有个硬盘,它有两个分区,第一个分区是ext2格式,第二个分区windows无法识别。这种情况下怎样得到这个硬盘的剩余大小。请各位积极参与,谢谢
GetDiskFreeSpaceEx只能得到具体分区的剩余容量情况。
我现在有个硬盘,它有两个分区,第一个分区是ext2格式,第二个分区windows无法识别。这种情况下怎样得到这个硬盘的剩余大小。请各位积极参与,谢谢
调试欢乐多
BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device
IOCTL_DISK_GET_LENGTH_INFO, // dwIoControlCode
NULL, // lpInBuffer
0, // nInBufferSize
(LPVOID) lpOutBuffer, // output buffer
(DWORD) nOutBufferSize, // size of output buffer
(LPDWORD) lpBytesReturned, // number of bytes returned
(LPOVERLAPPED) lpOverlapped // OVERLAPPED structure
);
Parameters
hDevice
[in] Handle to the disk, volume, or partition. To retrieve a device handle, call the CreateFile function.
dwIoControlCode
[in] Control code for the operation. Use IOCTL_DISK_GET_LENGTH_INFO for this operation.
lpInBuffer
Not used with this operation; set to NULL.
nInBufferSize
Not used with this operation; set to zero.
lpOutBuffer
[out] Pointer to the output buffer that receives a GET_LENGTH_INFORMATION structure.
nOutBufferSize
[in] Size of the output buffer, in bytes.
lpBytesReturned
[out] Pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.lpOverlapped
[in] Pointer to an OVERLAPPED structure.
If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored. If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways. For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.Return Values
If the operation succeeds, DeviceIoControl returns a nonzero value.If the operation fails, DeviceIoControl returns zero. To get extended error information, call GetLastError.Res
This operation should be used instead of IOCTL_DISK_GET_PARTITION_INFO_EX for volumes that do not have partition info—such as partition type or number of hidden sectors.Requirements
Client Requires Windows XP.
Server Requires Windows Server 2003.
Header Declared in Winioctl.h.
LogicalDisk\% Free Space\D: : [19.618]
LogicalDisk\% Free Space\E: : [11.815]
LogicalDisk\% Free Space\F: : [31.952]
LogicalDisk\% Free Space\_Total : [29.096]
LogicalDisk\Free Megabytes\C: : [21371.000]
LogicalDisk\Free Megabytes\D: : [9808.000]
LogicalDisk\Free Megabytes\E: : [3544.000]
LogicalDisk\Free Megabytes\F: : [34660.000]
LogicalDisk\Free Megabytes\_Total : [69383.000]