[Delphi (Object Pascal)] Delphi 返回驱动器文件系统名称 →→→→→进入此内容的聊天室

来自 , 2019-04-03, 写在 Delphi (Object Pascal), 查看 124 次.
URL http://www.code666.cn/view/6528f3f1
  1. function FileSystemName(const Drive: string): string;
  2. var
  3.   Unused: Cardinal;                             // unused parameters
  4.   PrevErrorMode: Windows.UINT;                  // stores Windows error mode
  5.   FileSys: array[0..Windows.MAX_PATH] of Char;  // receives name of file system
  6. begin
  7.   // Inhibit system dialog appearing on error
  8.   PrevErrorMode := Windows.SetErrorMode(
  9.     Windows.SEM_FAILCRITICALERRORS
  10.   );
  11.   try
  12.     // Get volume information
  13.     Result := '';
  14.     if Windows.GetVolumeInformation(
  15.       PChar(Drive), nil, 0, @Unused, Unused, Unused, FileSys, Windows.MAX_PATH
  16.     ) then
  17.     Result := FileSys;
  18.   finally
  19.     // Restore old error mode
  20.     Windows.SetErrorMode(PrevErrorMode);
  21.   end;
  22. end;
  23. //delphi/2200

回复 "Delphi 返回驱动器文件系统名称"

这儿你可以回复上面这条便签

captcha