Delphi Call Winapi:getvolumeinformation

Source: Internet
Author: User

Statement:GetVolumeInformation(
 lpRootPathName: PChar;        {磁盘驱动器代码字符串}
 lpVolumeNameBuffer: PChar;      {磁盘驱动器卷标名称}
 nVolumeNameSize: DWORD;       {磁盘驱动器卷标名称长度}
 lpVolumeSerialNumber: PDWORD;    {磁盘驱动器卷标序列号}
 var lpMaximumComponentLength: DWORD; {系统允许的最大文件名长度}
 var lpFileSystemFlags: DWORD;    {文件系统标识}
 lpFileSystemNameBuffer: PChar;    {文件操作系统名称}
 nFileSystemNameSize: DWORD      {文件操作系统名称长度}
): BOOL;

Example:

procedure TForm1.FormCreate(Sender: TObject);
var
 RootPath: array[0..20] of Char;
 VolName: array[0..255] of Char;
 SerialNumber: DWORD;
 MaxCLength: DWORD;
 FileSysFlag: DWORD;
 FileSysName: array[0..255] of Char;
begin
 RootPath := 'C:\';
 GetVolumeInformation(
  RootPath,
  VolName,
  255,
  @SerialNumber,
  MaxCLength,
  FileSysFlag,
  FileSysName,
  255
 );
 Memo1.Clear;
 with Memo1.Lines do
 begin
  Add(Format('磁盘驱动器代码字符串:'+ #9#9 +'%s',[RootPath]));
  Add(Format('磁盘驱动器卷标名称:'+ #9#9 +'%s',[VolName]));
  Add(Format('磁盘驱动器卷标序列号:'+ #9#9 +'%s',[IntToHex (SerialNumber,8)]));
  Add(Format('系统允许的最大文件名长度:'+ #9 +'%d',[MaxCLength]));
  Add(Format('文件系统标识:'+ #9#9#9 +'%d',[FileSysFlag]));
  Add(Format('文件系统名称:'+ #9#9#9 +'%s',[FileSysName]));
 end;
end;

Effect Chart:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.