I am searching for all drives and their contents. I don't want to search network drives. How can I determine if a given drive is network mounted? What I would want further is to get similar information one gets using NET USE command?
You want the GetDriveType function.
Also if you would like to add remove drives or check status, check this article out:
http://support.microsoft.com/kb/173011
That's using the win32 api.
Related
There are some applications (let us call them providers), which (when running) provide a virtual file and directory structure under a new drive letter. Access requests from other processes to those files and directories are served by the provider.
One example of such provider could be the Google Drive for Windows (the new one, not the old Backup and Sync), which maps the contents of your Google Drive to a chosen drive letter.
I thought there should be some simple user-mode API, which should allow my app to provide a new drive and the contents of files and directories on it. I thought that many applications use such API, but I cannot find it. The closest I could get are IFS (installable file system drivers) and file system filter drivers, but those are kernel-mode and they seem too complex. They just seem not designed to accomplish such task.
So, what API should I use to make a simple software-implemented drive?
In addition to the suggestions in the comments there is also now the Projected Filesystem, which allows software to provide a drive-like interface though callbacks and not just by creating an actual disk image. It is my understanding that Projected FS is how, for instance, SQL Server does its table-backed files interface.
Great information on interrogating mounted drives via IOKit in this question. But is there a way to determine which of the devices returned by IOIteratorNext() is the boot drive? Or better yet, might there be a way to get just the boot drive in the iterator returned by IOServiceGetMatchingServices()?
Booting is done from media, not a device per se. Devices have media, media have volumes. I don't believe that volumes are represented in IOKit.
This is probably easiest using Disk Arbitration. Use DADiskCreateFromVolumePath() with the CFURL for /. Then call DADiskCopyDescription() to get the description dictionary. That will include properties of the volume, the media, the device, and even the bus, including IOKit paths if you need them. There's a good chance the information you're looking for is directly in the description dictionary, though.
The NVRAM information cited by Mark Setchell is available from IOKit, too, at path IOService:/AppleACPIPlatformExpert/AppleEFIRuntime/AppleEFINVRAM. There's a property efi-boot-device. Its value is a property list including a service matching dictionary. As you can see, it looks for an entry with provider class of IOMedia whose UUID property is a certain UUID.
You can use this:
nvram efi-boot-device
efi-boot-device <array><dict><key>IOMatch</key><dict><key>IOProviderClass</key><string>IOMedia</string><key>IOPropertyMatch</key><dict><key>UUID</key><string>78025031-4C42-4FDE-8DD1-A515A2BF6032</string></dict></dict><key>BLLastBSDName</key><string>disk0s3</string></dict></array>%00
By using a FileSystemWatcher, in its events, I want to know the computer name or the IP or the user that triggered that event.
I know it's not possible directly with the FileSystemWatcher, but I was wondering if Windows stores that information for the File System.
So, could you at least point me where to start looking for it? If there's any Win Api to do such thing or something like that, even if in a very low-level?
EDIT:
Clarifying even more:
I wan't a low-level API or something of the sort that gives me the last user who modified the file in question.
Simple question, but I can't seem to find the answer anywhere. Is there a way in Windows, or via a third-party utility, to enforce file naming conventions within a Windows network share?
I'm sure this is easy in Sharepoint, but I want to be able to limit users to the file name format they save into a folder. I could create a post-save program to go and look for exceptions after the fact, but I want to try and force the user to name the files according to our standards when they save.
If something is not available/configurable on the server-side, could this be accomplished via VBA in Excel or Word in the save-file dialogue?
Thanks for your help.
A
There is nothing, to my knowledge, that can restrict file names.
Nothing unless you write it yourself.
How about monitoring the folder for changes and as soon as a file with the "wrong" file name is created you alert the user in some way?
Idealy you'd want a "hook" of some sort on the file system level that will also let you fail the file operation if the filename is wrong; but I don't think there's anything at user (not kernel) level that does this.
You will have to write a program to act as a gateway to the share to enforce this. You'll also have to restrict access to the share so users cannot circumvent the program.
I need to get some information that is contained in the MFT on a Windows machine, and I'm hoping that there is some super-secret API for getting this information. I need to be able to get to this information programmatically, and because of legal concerns I might not be able to use the tools provided by the company formally known as sysinternals.
My other option (which I really don't want to have to do) is to get the start sector of the MFT with DeviceIoControl, and manually parse through the information.
Anyway, in particular, what I really need to get out of the Master File Table is the logical sectors used to hold the data that is associated with a file.
There is a documented API for getting info on file positions on disk since Windows 2000. Look for DeviceIoControl function with FSCTL_GET_RETRIEVAL_POINTERS control code on MSDN:
http://msdn.microsoft.com/en-us/library/aa364572(VS.85).aspx
The API has been provided for writing custom disk defragmenters and consists of several other control codes.