检测是否在Visual C ++中打开了文件? [英] Detect if opened a file in visual c++?

查看:94
本文介绍了检测是否在Visual C ++中打开了文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个项目,我的项目将监视指定的文件,如果打开了该文件,我的项目将调用某个命令.如何检测文件是否已打开?我使用Visual C ++ 2010

I want to create a project, and my project will monitor the specified file, if the file is opened, my project will call a certain command. how do I detect if the file is opened? i use visual c++ 2010

推荐答案

也许会有所帮助:
使用FileSystemWatcher监视多个文件 [
Maybe this will help:
Monitor Multiple Files using FileSystemWatcher[^]

You can adapt the C# code to C++/CLI.


好吧,如果以某种排他访问方式打开文件,则可以通过尝试打开文件来知道它会失败,因为该文件已经打开.

但是并非所有程序在编辑文件时都保持打开文件的状态.
Well if the file is opened with some kind of exclusive access, then you could know by trying to open the file and it will fails because the file is already opened.

But not all program keep their file opened while editing them.


这篇关于检测是否在Visual C ++中打开了文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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