如何使用MFC监视文件 [英] How to Monitor the files using MFC

查看:143
本文介绍了如何使用MFC监视文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在MFC中开发应用程序,我的应用程序需要监视系统中已重命名或删除或创建了该文件的所有目录.我还必须记录所有这些内容以及路径,时间和名称的文件.

我一直在网上寻找,但是我发现大多数使用C#的文件监视程序,但是我需要在MFC中进行开发,因此,任何人都可以指导我在MFC中完成此操作.

在Advance中致谢

Hello

I am developing an application in MFC, my application need to monitor all the directories in the system that which file has been renamed or deleted or created.And i have to a make a log of all this things along with the path,time and name of the file.

I was looking in the net but i found most of the file watcher in C# but i need to develop in MFC,So kindly can any one guide me to complete this in MFC.

Thanks in Advance

推荐答案

可以通过WMI完成,所以请使用MFC遍历WMI.

所需查询可以表述为:

It can be done with WMI, so please go thru WMI with MFC.

The required query can be formulated as :

SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA "CIM_DirectoryContainsFile" and TargetInstance.GroupComponent= "Win32_Directory.Name='C:\\Test\\MyFolderToMonitor'"



现在,您可以使用它来构建基于WMI的文件更改通知事件.

可能对您有帮助吗?
http://msdn.microsoft.com/zh-CN /library/windows/desktop/aa390425(v=vs.85).aspx [



Now you can use this to build WMI based File Change notification event.

May this too help you:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa390425(v=vs.85).aspx[^]


看看
Have a look at Change Journals[^]. It''s better than using FindFirstChangeNotification or ReadDirectoryChangesW.

Best regards
Espen Harlinn


这篇关于如何使用MFC监视文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆