如何获取当前使用vb6运行的进程的文件名 [英] How to get the filename of the process that is currently runing using vb6

查看:299
本文介绍了如何获取当前使用vb6运行的进程的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从Excel或Word进程等找到当前打开的文件? ,我想得到Windows中所有正在运行的进程列表以及它们当前打开的文件。



提前致谢!

is there a way to find the currently open file from Excel or Word process etc? , i want to get all the list of running processes in windows and which files they currently have open.

Thanks in advance!

推荐答案

测试它:

Test it:
Option Explicit

Sub EnumWordRunningFiles()
Dim WrdApp As Object, file As Object

On Error GoTo Err_EnumWordRunningFiles

Set WrdApp = GetObject(, "Word.Application")
For Each file In WrdApp.Documents
    MsgBox file.FullName, vbInformation, "Message"
Next

Exit_EnumWordRunningFiles:
    Set WrdApp = Nothing
    Exit Sub

Err_EnumWordRunningFiles:
    MsgBox Err.Description, vbExclamation, "Error No. " & Err.Number
    Resume Exit_EnumWordRunningFiles
End Sub


Sub EnumExcelRunningFiles()
Dim ExcApp As Object, file As Object

On Error GoTo Err_EnumExcelRunningFiles

Set ExcApp = GetObject(, "Excel.Application")
For Each file In ExcApp.Workbooks
    MsgBox file.Name, vbInformation, "Message"
Next

Exit_EnumExcelRunningFiles:
    Set ExcApp = Nothing
    Exit Sub

Err_EnumExcelRunningFiles:
    MsgBox Err.Description, vbExclamation, "Error No. " & Err.Number
    Resume Exit_EnumExcelRunningFiles
End Sub


http ://www.mattsbits.co.uk/item-150.html [ ^ ]



我复制了部分问题并搜索了Google。这是我发现的第一个打击。



- 祝你好运。
http://www.mattsbits.co.uk/item-150.html[^]

I copied part of your question and searched Google. This is the first hit I found.

-- good luck.


这篇关于如何获取当前使用vb6运行的进程的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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