noch eine letzte Hilfestellung.
16.06.2009 08:53:02
Tino
Hallo,
ich habe den Verdacht, dass Du nicht nach dem richtigen Fenstertitel suchst.
Mach mal eine neue Datei, fügen diesen Code in ein Modul ein und starten die Sub vList_Prozesse.
Kannst Du Deine Anwendung mit dem Titel in der Liste finden?
Solltest Du Deine Anwendung finden, verwende diesen Titel.
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () _
As Long
Private Declare Function GetWindow Lib "user32" _
(ByVal hWnd As Long, ByVal wCmd 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
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 GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hWnd As Long) _
As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As _
Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd _
As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDLAST = 1
Const GW_HWNDNEXT = 2
Const GW_HWNDPREV = 3
Const GW_OWNER = 4
Const GW_CHILD = 5
Const GW_MAX = 5
Const GWL_STYLE = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Private Sub GetWindowInfo(ByVal hWnd&, bVisible As Boolean, booMit_Titel As Boolean)
Dim Parent&, Task&, Result&, X&, Style&, Title$
'Darstellung des Fensters
Style = GetWindowLong(hWnd, GWL_STYLE)
Style = Style And (WS_VISIBLE Or WS_BORDER)
Result = GetWindowTextLength(hWnd) + 1
Title = Space$(Result)
Result = GetWindowText(hWnd, Title, Result)
Title = Left$(Title, Len(Title) - 1)
If (Style = (WS_VISIBLE Or WS_BORDER)) Or bVisible = False Then
If Title <> "" Or booMit_Titel = False Then
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = CStr(hWnd)
Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) = Title
'Elternfenster ermitteln
Parent = hWnd
Do
Parent = GetParent(Parent)
Loop Until Parent = 0
'Task Id ermitteln
Result = GetWindowThreadProcessId(hWnd, Task)
Cells(Rows.Count, 3).End(xlUp).Offset(1, 0) = Task
End If
End If
End Sub
Sub vList_Prozesse()
Dim hWnd As Long, tbuf As String, RetVal As Long
'Zellen leeren und Überschrift
Cells.Clear
Range("A1") = "hwnd"
Range("B1") = "Titel"
Range("C1") = "Prozess ID"
Range("A1:C1").Font.Bold = True
'______________________________
'hwnd Deskdopt
hWnd = GetDesktopWindow()
hWnd = GetWindow(hWnd, GW_CHILD)
'hwnd, nur Sichtbar, nur Mit Fenstertitel
GetWindowInfo hWnd, True, True
Do While hWnd <> 0
tbuf = String(255, 0)
RetVal = GetWindowText(hWnd, tbuf, Len(tbuf))
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
'hwnd, nur Sichtbar, nur mit Fenstertitel
GetWindowInfo hWnd, True, True
Loop
Columns("A:C").EntireColumn.AutoFit
End Sub
Sonst habe ich jetzt keine weiteren Möglichkeiten.
Gruß Tino