AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Is volume compressed?

Ein Thema von WojTec · begonnen am 5. Feb 2014 · letzter Beitrag vom 6. Feb 2014
 
Der schöne Günther

Registriert seit: 6. Mär 2013
6.199 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: Is volume compressed?

  Alt 6. Feb 2014, 11:43
I might be wrong, but I believe there is no clear indication if a volume is either compressed or not compressed at all. We're talking about NTFS, right? I think the FILE_VOLUME_IS_COMPRESSED flag still hails from the time of the FAT file system. Back then, a volume was either entirely compressed ("double space volume") or no compression at all was taking place.

Take a look: Set a volume of yours to "compressed". Create some folders, they're all blue (compressed). Now set a folder to "uncompressed". Your volume will still state "compressed". I believe "volume compression" only means "Default setting for compressing content or not".

Keeping this in mind, this is what I baked together:
Delphi-Quellcode:
procedure TForm18.checkCompression();
const
   // According to http://www.swissdelphicenter.ch/en/showcode.php?id=1053
   COMPRESSION_FORMAT_NONE = 0;
   COMPRESSION_FORMAT_LZNT1 = 2;
   COMPRESSION_FORMAT_DEFAULT = 1;
var
   fileHandle: THandle;
   outBuffer: ^USHORT;
   bufferLength: DWORD;
begin


   // Fetch Handle
   fileHandle := CreateFile(
      'F:\.',
      GENERIC_READ,
      FILE_SHARE_READ,
      nil,
      OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL or FILE_FLAG_BACKUP_SEMANTICS,
      0
   );

   if (fileHandle = INVALID_HANDLE_VALUE) then raise Exception.Create('CreateFile Failed');

   // Init Buffer
   New(outBuffer);

   if not DeviceIoControl(
      fileHandle,
      FSCTL_GET_COMPRESSION,
      nil,
      0,
      outBuffer,
      SizeOf(outBuffer),
      bufferLength,
      nil
   ) then raise Exception.Create('DeviceIoControl failed');

   if (outBuffer^ and COMPRESSION_FORMAT_LZNT1) <> 0 then
      ShowMessage('it is compressed');


end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz