Contents
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Search
Login
Who Is Online?
We have 42 guests online
Navigation
Home Source Code C/C++ NTFS compression
Most Recent
Featured Articles
Joomla 1.5 Featured Articles
Navigation
Home Source Code C/C++ NTFS compression
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
NTFS compression E-mail
User Rating: / 6
PoorBest 
Source Code - C/C++
Written by Thomas   
Sunday, 01 February 2009 22:12

 

A function to compress a file by utilising NTFS's compression feature.

 

Open CompressNTFS.c
 

CompressNTFS.c:

 
#include <windows.h>
 
BOOL CompressFileNTFSEx (const TCHAR *tcFileName, USHORT usState)
{  // Compress or uncompress the given file.
  //
  //  usState can be:
  //  0 = COMPRESSION_FORMAT_NONE
  //  1 = COMPRESSION_FORMAT_DEFAULT
  //  2 = COMPRESSION_FORMAT_LZNT1
  //
  //  Returns TRUE if successful, FALSE if an error occurred.
  //
 
  HANDLE    hFile;
  DWORD    dwBytesReturned;
  BOOL    bResult;
 
  //return FALSE;
 
  hFile = CreateFile (tcFileName,
          GENERIC_READ | GENERIC_WRITE,
          FILE_SHARE_DELETE + FILE_SHARE_READ + FILE_SHARE_WRITE,
          NULL,
          OPEN_EXISTING,
          FILE_ATTRIBUTE_NORMAL + FILE_FLAG_SEQUENTIAL_SCAN,
          NULL);
  if (hFile == INVALID_HANDLE_VALUE)
    return FALSE;
  bResult = DeviceIoControl (hFile,      // Handle to file or directory
            FSCTL_SET_COMPRESSION,  // dwIoControlCode
            &usState,        // Input buffer
            sizeof (USHORT),    // Size of input buffer
            NULL,          // lpOutBuffer
            0,            // nOutBufferSize
            &dwBytesReturned,    // Number of bytes returned
            NULL          // OVERLAPPED structure
            );
  if (!CloseHandle (hFile))
    return FALSE;
  return (bResult);
}
 
BOOL CompressFileNTFS (const TCHAR *tcFileName)
{
  return (CompressFileNTFSEx (tcFileName, COMPRESSION_FORMAT_DEFAULT));
}
 
BOOL UnCompressFileNTFS (const TCHAR *tcFileName)
{
  return (CompressFileNTFSEx (tcFileName, COMPRESSION_FORMAT_NONE));
}
 
Open CompressNTFS.c

 

Open CompressNTFS.h
 

CompressNTFS.h:

 
#ifndef __Compress_NTFS_included
#define __Compress_NTFS_included
 
BOOL CompressFileNTFSEx (const TCHAR *tcFileName, USHORT usState);
BOOL CompressFileNTFS (const TCHAR *tcFileName);
BOOL UnCompressFileNTFS (const TCHAR *tcFileName);
 
#endif
 
Open CompressNTFS.h
 

 

Last Updated on Sunday, 08 February 2009 18:56
 
You need to login or register to post comments.
Discuss this item on the forums. (8 posts)
Discuss (8 posts)
NTFS compression
Aug 06 2015 11:42:44
Fixierung auf dem Platz braucht! Überprüfen Sie dieses heraus sonst wo auf Kamagra
#2232
Re: NTFS compression
Mar 07 2012 17:31:34
It had something to do with removed articles. It's still not fully fixed. I'll have a look at this within the next few days.
#1248
Re: NTFS compression
Mar 06 2012 13:04:03
And what has happened ? ;/ (trollface.jpg)
#1247
Re: NTFS compression
Mar 06 2012 02:28:00
Ah, yeah. I think we found out what happened. Should be fixed now.
#1246
NTFS compression
Mar 05 2012 23:00:32
I've seen both Eagleeye and Death race. They're both good movies. I think Death race is better because it has cars that look like Mad Max cars and a famous actor Jason in it.
Oh, There's a Death Race sequel by the way. I haven't seen it yet.
#1245
Re: NTFS compression
Mar 05 2012 11:19:11
LOL. Is it possible that you did not quite understand the subject?
#1243
NTFS compression
Mar 04 2012 20:10:55
Seen this movie. It's an awesome movie with the cars that look like the cars from Mad Max. Jason is a good at what he does.
#1241
NTFS compression
Mar 04 2012 20:07:02
Seen it, good movie.
#1240