I have some code which compresses a whole folder structure, and it works OK,
but I have admin privileges. For someone who doesn't, my code fails --
however they can successfully right-click a folder, choose Properties, and
use the Advanced button to compress its whole structure and all contents. So
the problem is, I'm asking for too much permission in my code.
Here's the essence of my VB code:
Sub Compress(sFileOrFolder as String)
Dim lFileHwnd As Long, lBytesRtn As Long, iOutput As Integer, lResult as
Long
lFileHwnd = CreateFile(sFileOrFolder, GENERIC_ALL, 0&, 0&,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0&)
lResult = DeviceIoControl(lFileHwnd, FSCTL_SET_COMPRESSION,
COMPRESSION_FORMAT_DEFAULT, 2&, iOutput, 2&, lBytesRtn, 0&)
End Sub
I've found other code out there with many different settings for the
parameters to CreateFile, even one with dwDesiredAccess (#2) set to only
GENERIC_READ, but none mentioning FILE_WRITE_EA or FILE_WRITE_ATTRIBUTES,
which seems to make sense. Also, it seems to me there should be no sharing
during compression, but I see code with dwShareMode (#3) set to SHARE_ALL,
etc., all over.
What's the bare minimum access and sharing I really need to compress files
and folders? Thanks.

Signature
Andy Smith
Senior Systems Analyst
Standard and Poor''s, NYC
Anand.V.V.N - 30 Nov 2007 15:20 GMT
Hello,
Not sure if this makes sense, I think the bare minimum permission would that
you have to be the creator of the folder/files, another thing would be that
you have to have read and write permission on the folder/file I think
Anand

Signature
"Who will guard the guards?"
> I have some code which compresses a whole folder structure, and it works OK,
> but I have admin privileges. For someone who doesn't, my code fails --
[quoted text clipped - 25 lines]
> What's the bare minimum access and sharing I really need to compress files
> and folders? Thanks.