vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
NEU! sevCoolbar 3.0 - Professionelle Toolbars im modernen Design!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB & Windows API
Re: Prozess Owner 
Autor: majoo
Datum: 11.03.04 17:23

Hallo, anbei der gesamte Code. Ich habe den Fehler bisher nicht gefunden.
Aber erst mal vielen Dank für die Hilfe. Das Ganze soll später auf einem Term-Server laufen, damit User hängende Prozesse selbst beenden können. Wenn es nicht mehr abstürzt, kommt noch ein wenig Funktionalität (Userbezogen) dazu.

Bis bald Majoo

Code stamm teilweise hier aus dem Forum:
Teil1

rem Modul ProzessID
Option Explicit

Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd 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 GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId 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
Global Owner
Public Function GetWindowList(oLSV As ListView, Optional bVisible As Boolean = True)

Dim hWnd As Long
Dim sTitle As String
Dim lTaskID As Long
Dim lStyle As Long
Dim oListItem As ListItem


' ListView-Spalten festlegen
With oLSV.ColumnHeaders
.Clear
.Add , "hWnd", "hWnd"
.Add , "TaskID", "TaskID"
.Add , "Visible", "Visible"
.Add , "Title", "Title"
.Add , "Owner", "Owner"
End With

' Inhalt löschen und umschalten auf "Detail"-Ansicht
oLSV.ListItems.Clear
oLSV.View = lvwReport

' Erstes WindowHandle holen
hWnd = GetWindow(oLSV.Parent.hWnd, GW_HWNDFIRST)

Do
' Handle auswerten und im ListView eintragen
lStyle = GetWindowLong(hWnd, GWL_STYLE)
lStyle = lStyle And (WS_VISIBLE Or WS_BORDER)
sTitle = GetWindowTitle(hWnd)
lTaskID = GetWindowTaskID(hWnd)


If (lStyle = (WS_VISIBLE Or WS_BORDER)) = bVisible Then
' in das ListView eintragen
Set oListItem = oLSV.ListItems.Add(, , hWnd)
With oListItem
.SubItems(1) = lTaskID
.SubItems(2) = lStyle = (WS_VISIBLE Or WS_BORDER)
.SubItems(3) = sTitle
Call GetProcessUserName(lTaskID)
.SubItems(4) = Owner
End With

End If

' Nächses Handle
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
Loop Until hWnd = 0
End Function
Private Function GetWindowTaskID(ByVal hWnd As Long) As Long

Dim lResult As Long
Dim lTemp As Long

lResult = GetWindowThreadProcessId(hWnd, lTemp)
GetWindowTaskID = lTemp

End Function
Private Function GetWindowTitle(ByVal hWnd As Long) As String

Dim lResult As Long
Dim sTemp As String

lResult = GetWindowTextLength(hWnd) + 1
sTemp = Space(lResult)
lResult = GetWindowText(hWnd, sTemp, lResult)
GetWindowTitle = Left(sTemp, Len(sTemp) - 1)
End Function
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Prozess Owner2.323majoo10.03.04 22:07
Re: Prozess Owner1.598E711.03.04 16:09
Re: Prozess Owner1.669majoo11.03.04 17:23
Re: Prozess Owner1.619majoo11.03.04 17:24
Re: Prozess Owner1.572majoo11.03.04 17:24
Re: Prozess Owner1.518Obi18.03.04 09:22
Re: Prozess Owner1.431majoo18.03.04 20:52
Re: Prozess Owner1.461Obi18.03.04 21:25
Re: Prozess Owner1.413majoo20.03.04 16:08
Re: Prozess Owner1.383Obi20.03.04 17:15
Re: Prozess Owner1.351majoo20.03.04 18:51
Re: Prozess Owner1.355Dubs23.03.04 15:58
Re: Prozess Owner3.281Obi26.03.04 23:40
Re: Prozess Owner1.566majoo27.03.04 10:05

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel