开发者

CreateFile() for RegisterDeviceNotification() with UAC

开发者 https://www.devze.com 2023-02-10 04:12 出处:网络
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.

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 Admini开发者_如何学编程strator privileges at all?

Thanks in advance.


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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消