How to Get File security attribute in windows - c++

I am using c++ MFC
How can I get the file security attribute in windows, is there any handy api?
Many thanks!

Could you please check
The Windows Access Control Model Part 1
The Windows Access Control Model: Part 2
Also, take a look here Windows Access Control

Are you looking for something like this?
http://msdn.microsoft.com/en-us/library/aa446639(VS.85).aspx

There's no handy C++ API, at least not in MFC. The CFile model supports any kind of file system: NTFS, but also FAT and CDFS (for CD-ROMs). Hence it generalized a lot. NTFS-specific features such as ACL, ADS etcetera are not supported. You'll still need to use the raw Win32 API for that.

Related

How do I retrieve the file Property metadata in Windows from within QT?

I couldn't find a good answer for this.
What is the code for looking at the metadata of an executable file, like Description and Company, or the API reference guide for doing such a thing?
I have looked through QFileInfo, but the code can only read and output the basic cross platform information like names, path, and times.
I dont think there is a Qt'ish way to do it, because such information is not really cross-platform. As it was mentioned in comments best way to use windows API for this.
I faced once similar problem when I had to handle all this information within cross-platform project. So goal was to keep all metadata available through cross-platform builds as well as showing it properly on Windows File Properties dialog. Most fast solution I was able to come up with is to define all this information via #define in one version.h, so it became to be available within software and reuse same defines in windows RC file which included version.h and was included itself in the .pro under win32 condition.

Extended file attributes on windows (ntfs)

I'm currently working on a cross platform application that uses extended file attributes for storing it's own file ownership information (uid, gid) outside of the normal filesystem ownership. This information is application specific and has nothing to do with the normal filesystem ownership.
I just changed from using a small database stored in each folder for storing this information for performance reasons, but this leaves my solution lacking on the Windows platform.
According to wikipedia, NTFS may have some limited functionality as far as being able to store extended file attributes, but I certainly can't find any further information on how to get and set these attributes.
Has anyone done this before and can tell me how to do it? Or is it just plain not possible?
I'd ideally like to not have to revert to the database solution on Windows.
Maybe NTFS streams are what you are searching for?
Read more here: http://support.microsoft.com/kb/105763 , http://msdn.microsoft.com/en-us/library/ff469210.aspx

Windows C/C++ Drive Init/Partition/Format

I am trying to build an application for Windows XP 64bit which is able to detect drives of a particular model in the system, and if they are not initialized & formatted perform these processes.
I would also like to be able to query and set the partition information(including the volume label).
I have started putting together code using DeviceIoControl, but I have not been able to figure out how to set/get partition/volume labels or format drives with the method, I have got SMART access working.
Is there any other method that is any easier to use?
Zac
Sounds like you are looking for Disk Management Control Codes.
If I were doing this I would use my own code only to detect things. I would do the partitioning and formatting through diskpart and/or format commands instead. diskpart accepts file argument with a script to execute.

Is there a C++ cross platform key/value API or library for C++?

We want to persist some user settings int he GUI part of our code. I used to do Win32 programming exclusively and the typical way this was done was with registry settings.
I assume that this should be done with configuration files, but was wondering if there was a library or cross platform wrapper that made key/value pair persistence very easy.
Qt's QSettings class handles this:
http://doc.qt.nokia.com/4.6/qsettings.html
Boost.PropertyTree supports XML, JSON, INI config files.
There is also JSON for a lighter alternative of XML. Lots of implementations on that page too.
Qt 4 has a class for it, named QSettings. Looks exactly like what you need.
Why not use an XML as the configuration file. Then you only have to find a cross platform XML library which is easier IMO.
Here is a list of nice XML parsing solutions for C++.
Old school Berkley DB comes to mind.
Have a look at Tokyo Cabinet or at Embedded InnoDB.
In the old days we used .ini files in windows. Here is a portable version of an ini file read/write library
It will work on Windows as well as Linux.

How can I write my own 'filesystem' within Windows?

I've recalled using little 'filesystems' before that basically provided an interface to something else. For example, I believe there was a GMail filesystem that created an entry in My Computer and could be used like any other drive on your local computer. How can I go about implementing something like this in C++?
Thank you!
Try Dokan. It's like FUSE, except for Windows. I think there are certain limitations to namespace extensions, like they cannot be accessed from the command line, but I'm really not sure as of now.
Writing an actual file-system involves writing a driver; which means kernel-mode code (scary stuff) and paying for getting the IFS DDK. (edit: looks like they don't charge for it anymore)
What you probably want is a “namespace extension”.
Try this: The Complete Idiot's Guide to Writing Namespace Extensions - CodeProject
This may be a starting point to extending NTFS in the way that the GMail filesystem used to do: Windows NT reparse points.
The GMail Filesystem is just the name given; it is not any filesystem as such. It is just a namespace extension for Windows Explorer that links with the GMail account of yours!
I dont know exactly what you are trying to do, but in anyway, I believe, the following link will be of some use to you:
http://msdn.microsoft.com/en-us/magazine/cc188741.aspx
Just as a reference: virtual drives can be created using our Callback File System product, which is a supported, documented and maintained solution.
I was thinking of this too, perhaps some example code ? (email me if i forget plz ;p doin sdk now)
I'm thinking of a similar filesystem that would plug in as a driver and allow dynamic 'soft raid' on larger files mostly by putting them on more than one disk, perhaps some compression options and 'smart' filters to toggle usage in high disk space low usage and other situations more effectively, with status controls and indicators as a normalish program too
Seems like I would load the driver kit,
then i want the file writing event, and am mostly replacing fopen and similar functions automatically as an intermediate driver with a little windows network driver experience
I also heard good things about developing on a virtual machine for less crashing and more debugging
Also perhaps more metainfo on some or all files, including files in special folders with options too, including maybe both fast and simple (obfuscated and/or symmetic key) encryption options on folder, specified, all, letter, etc, or whatever, or the slower version and maybe integrated and optional (also profitable) online cvs-like diff style backups that mostly target changes to hot files for online backup at intervals and prices, mostly perhaps with matching keyboard events and might even be useful as simply a keylogging online backup service that is reasonably secure too
while avoiding common files like windows files or the normal stuff in the 'programs' directory that can be copied easily with pirate tools, unlike all of your documents.