如何查找当前打开的 MS Office 文档的名称?
我想找到当前在我的操作系统上打开的 Office 文档的名称(任何像 exel、word、access...等)。这一切都是通过我的 C# 代码完成的。
如果有人对此有任何想法,请分享。
我为此创建了共享加载项,并记录了该文档的打开、关闭时间以及用户在该文档上花费的时间,该时间也被记录并输入到数据库中,但只有文件名没有获取并输入到数据库中。
更新: 我有一个用 C#.net 开发的基于桌面的应用程序。 我想在我的应用程序中做一些事情,以便当我们将此应用程序安装到客户端系统上并且客户端打开他的系统上的任何办公文档时,都会在我的数据库中后台记录,即他何时打开特定文件,何时关闭以及多少他在该文件上花费的时间以及使用该文件名在空闲状态(未完成任何工作)打开该文件的时间。 这是我的要求。
I want to find the name of office document(any like exel,word,access...etc) which is currently open on my operating system. It all is done through my C# code.
If any one have any idea on that, so please share it.
I created Shared add-in for that and also record the opening, closing time of that document and the time which the user spend on that is also recorded and did entry in database but only the name of file is not getting and entered into database.
UPDATE:
i have one desktop based application developed in C#.net.
i want to do something in to my application so that when we install this application onto client system and client open any of the office document on his system, is recorded backgroundly on my database i.e. when he open particular file,when he close and how much time he spend on this file and how much time this file is opened in idle state(no work is done) with the name of that file.
Its my requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所描述的应用程序听起来有点像与系统安全性相矛盾。该方案实际上类似于在后台运行的恶意软件,在不知不觉中悄然拦截各种用户的交互不管怎样
,回到技术解决方案,也许您可以通过检查打开/关闭文档时 MS Office 在注册表中留下的轨迹来找出一些东西。
MS Office 在注册表中存储 MRU 列表(请参阅如何清除 Office 程序中最近使用的列表 (MRU) 列表 以及有关注册表项详细信息的相关文章)。
因此,您可以定期扫描特定的注册表项,即每分钟一次,然后进行比较(MRU 的先前状态与当前状态),计算一些统计数据等。但这并不理想。
The application you are describing sounds a bit like staying in contradiction of system security. The scheme is actually similar to a malware working in background and intercepting various user's interactions, silently without awareness of a user, etc.
Anyway, back to technical solution, perhaps you figure out something based on checking tracks MS Office leaves in registry when a document is opened/closed.
MS Office stores MRU list in registry (see How to clear the Most Recently Used list (MRU) list in Office programs and related articles for details of registry keys).
So, you could scan particular registry keys periodically, i.e. once a minute, then make comparisons (previous vs current state of MRU), calculate some statistics, etc. It is not ideal though.
以下内容改编自: http://pinvoke.net/default.aspx/user32.EnumDesktopWindows< /a>
您将需要更改 EnumWindowsProc 过滤条件以满足您的需要。该代码查看窗口标题,但如果您需要文件路径,则可以使用 hWnd 来查找。
The following was adapted from : http://pinvoke.net/default.aspx/user32.EnumDesktopWindows
You will want to change the EnumWindowsProc filter criteria to match your needs. The code looks at the window title, but if you need the file path, you can use the hWnd to find that.