2012-04-19 2 views
0

Excel이나 Word 프로세스 등에서 현재 열려있는 파일을 찾는 방법이 있습니까? Windows에서 실행중인 모든 프로세스 목록과 현재 열려있는 파일 목록을 가져 오려고합니다.현재 vb6에서 실행중인 프로세스의 파일 이름을 얻는 방법

+1

음, 당신의 질문 1 부, 2 부, 일치하지 않습니다 제목으로 모든 Word 창을 나열합니다 ... – Deanna

+4

이제는 동일한 주제에 대한 세 가지 질문 중 두 번째로 나옵니다. 지금은 그렇게 작동하지 않습니다. (1) http://stackoverflow.com/questions/10202842/how-do-i-get-the-list-of-open-file-handles-by-process-in-vb6 (3) http : // stackoverflow .com/questions/10240742/view-opened-locked-files-in-my-system – Fionnuala

답변

1

이유가 무엇입니까, 왜 vb6을 사용합니까?

편집 : http://wiki.robotz.com/index.php/Process_List_and_Locate_VB6

+0

bcz 이미 vb.net에서이 작업을 수행했지만 Windows를 설치할 때마다 vb6에서이 작업을 수행하면 .net 프레임 워크가 설치됩니다. ... 아무 것도 설치할 필요가 없습니다 – user1153193

+0

링크를 보면 문제를 해결하는 데 도움이 될 수 있습니다. – chris6523

+0

Hwo .NET에서이 작업을 수행합니까? 동일한 개념/Win32 API가 다른 언어에서도 작동합니다. 또한 자신 만의 앱이 필요합니까? [Process Explorer] (http://technet.microsoft.com/en-us/sysinternals/bb896653)는 이미이 작업을 수행합니다. – Deanna

2

방법을 사용하여 실행중인 프로세스의 목록에 대한 : VB6에서 프로세스 목록을 얻는 방법을 몇 가지 예와, 그 당신을 도울 것입니다, 그러나 여기 링크가있는 경우 는 모르겠지만, 아마도 열려있는 창 목록이 더 유용 할 수 있습니다 http://www.windowsadminscripts.com/coding/networking/processes/

: VBA

Function getProcessInfo() 
''On Error Resume Next 
Dim objProcess, process, strNameOfUser 
ComputerName = "." 
Set objProcess = GetObject("winmgmts:{impersonationLevel=impersonate}\\" _ 
     & ComputerName & "\root\cimv2").ExecQuery("Select * From Win32_Process") 
For Each process In objProcess 
    If process.Name <> "System Idle Process" And process.Name <> "System" Then 
     ''Debug.Print process.Name 
     Debug.Print process.Name & "," & process.executablepath _ 
      & "," & process.Priority & "," & process.sessionid _ 
      & "," & strNameOfUser & "," & process.handlecount _ 
      & "," & process.ThreadCount 
    End If 
Next 

Set objProcess = Nothing 
End Function 

은 수정

Private Const GW_HWNDNEXT = 2 
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long 
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long 
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long 

Sub ListWins(Optional Title = "*", Optional Class = "*") 
    Dim hWndThis As Long 
    hWndThis = FindWindow(vbNullString, vbNullString) 
    While hWndThis 
     Dim sTitle As String, sClass As String 
     sTitle = Space$(255) 
     sTitle = Left$(sTitle, GetWindowText(hWndThis, sTitle, Len(sTitle))) 
     sClass = Space$(255) 
     sClass = Left$(sClass, GetClassName(hWndThis, sClass, Len(sClass))) 
     If sTitle Like Title And sClass Like Class Then 
      Debug.Print sTitle, sClass 
     End If 
     hWndThis = GetWindow(hWndThis, GW_HWNDNEXT) 
    Wend 
End Sub 

과 같이 그것을 사용 :

ListWins "*.doc*" 

이 포함 된 제목 .DOC

+0

Remou는 코드에 대해 매우 감사드립니다.이 코드는 응용 프로그램과 함께 실행되는 프로세스를 보여줍니다. wmplayer.exe proccess는 결과를 표시합니다. c : \ programfile \ windows 미디어 플레이어 등 Windows Media Player에서 실행중인 파일이 표시되지 않았습니다. 현재 실행중인 파일이 아닌 현재 실행중인 파일이 필요합니다. – user1153193

+0

http://social.technet.microsoft.com/Forums/ko/ITCG/thread/0c6a8b1b-c99e-402c-bf9b-a09343aaa724 – Fionnuala

+0

이 게시물이 없습니다 .. handle.exe가 좋다 도구이지만 명령 프롬프트에서 작업 중 – user1153193

관련 문제