Question

Is it possible to use RegisterDeviceNotification() for a system drive, with UAC enabled? It works perfectly without UAC, but with UAC CreateFile() fails with Access Denied.

Here is how CreateFile is called:

aHandle:=CreateFile(PChar(sDevice), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

Is there a way to adjust CreateFile() parameters to just get minimum read permissions for the drive, or is it not possible without Administrator privileges at all?

Thanks in advance.

Was it helpful?

Solution

Did you try using something other than GENERIC_READ? Even 0 might work. FILE_SHARE_READ is also a bit restrictive, you might have to run it in a loop and try all share modes...

OTHER TIPS

For file-system changes, FindFirstChangeNotification(MSDN) is your friend here. Just set up notifications for the directories you're interested in, and away you go. Search StackOverflow for this, and you'll get a number of hits on this topic.

To monitor disk space, GetDiskFreeSpaceEx(MSDN) is your friend. Just call it when you want the current state of the volume.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top