Windows|Windows API (与磁盘信息相关)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GetDriveType:用于判断驱动类型
UINT WINAPI GetDriveType(
_In_opt_ LPCTSTR lpRootPathName
);
文章图片
文章图片
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
以下内容摘录自MSDN && http://zhidao.baidu.com/question/64422451.html
GetVolumeInformation function
GetVolumeInformation( lpRootPathName: PChar; {根目录名} lpVolumeNameBuffer: PChar; {接收卷名的缓存} nVolumeNameSize: DWORD; {指定缓存大小} lpVolumeSerialNumber: PDWORD; {卷序列号指针} var lpMaximumComponentLength: DWORD; {maximum file component name} var lpFileSystemFlags: DWORD; {文件系统格式标记} lpFileSystemNameBuffer: PChar; {文件系统格式缓存} nFileSystemNameSize: DWORD {文件系统名称} ): BOOL; 下面为示例 procedure TForm1.Button1Click(Sender: TObject); var RootPath: array[0..20] of Char; // holds the root directory name VolName: array[0..255] of Char; // holds the volume name SerialNumber: DWORD; // holds the serial number MaxCLength: DWORD; // holds the maximum file component length FileSysFlag: DWORD; // holds file system flagsFileSysName: array[0..255] of Char; // holds the name of the file system begin {indicate information is to be retrieved from the C drive} RootPath := 'C:\'; {retrieve the volume information} GetVolumeInformation(RootPath, VolName, 255, @SerialNumber, MaxCLength, FileSysFlag, FileSysName, 255); {display the information} Panel2.Caption := VolName; Panel3.Caption := IntToHex(SerialNumber,8); Panel4.Caption := FileSysName; end;
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GetDiskFreeSpace
BOOL WINAPI GetDiskFreeSpace(
_In_LPCTSTR lpRootPathName,//传入参数
_Out_ LPDWORD lpSectorsPerCluster,
_Out_ LPDWORD lpBytesPerSector,
_Out_ LPDWORD lpNumberOfFreeClusters,
_Out_ LPDWORD lpTotalNumberOfClusters
);
该函数有4个输出值 , 对应分别是
每簇的扇区数,
每扇区的字节数,
簇剩余,
簇总计,
注意调用该函数的时候,在传参过程中,需要传入该参数的引用
EP:
GetDiskFreeSpace
(
lpRootPathName,
§orsPerCluster,
&bytesPerSector,
&numberOfFreeClusters,
&totalNumberOfClusters
);
MSDN的中关于GetDiskFreeSpace的使用限制:
GetDiskFreeSpace cannot report volume sizes that are greater than 2 GB.
To ensure that your application works with large capacity hard drives, use the GetDiskFreeSpaceEx function.\
//
GetDiskFreeSpaceEx
Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread.
BOOL WINAPI GetDiskFreeSpaceEx(
_In_opt_LPCTSTRlpDirectoryName,
_Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes,
_Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
【Windows|Windows API (与磁盘信息相关)】
推荐阅读
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- Docker应用:容器间通信与Mariadb数据库主从复制
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量
- 第326天
- Shell-Bash变量与运算符
- 2020-04-07vue中Axios的封装和API接口的管理
- 逻辑回归的理解与python示例
- Guava|Guava RateLimiter与限流算法
- 我和你之前距离
- CGI,FastCGI,PHP-CGI与PHP-FPM