' Spalten erstellen .Columns.Add("Prozess", 100, HorizontalAlignment.Left) .Columns.Add("Dateiname", 250, HorizontalAlignment.Left) .Columns.Add("pid", 50, HorizontalAlignment.Right) End With End Sub
' Liste aller Prozesse ermitteln Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click
Dim oItem As ListViewItem
With ListView1 ' ListView-Inhalt löschen .Items.Clear()
' alle Prozesse durchlaufen For Each oProcess As Process In Process.GetProcesses ' Prozess-Infos ermitteln und im ListView anzeigen oItem = .Items.Add(oProcess.ProcessName) Try oItem.SubItems.Add(oProcess.MainModule.FileName) Catch oItem.SubItems.Add("") End Try oItem.SubItems.Add(oProcess.Id.ToString) Next End With End Sub[/code]
Erweiterung: Visual Basic: [code]' Prozess beenden Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click
With ListView1 If .SelectedItems.Count > 0 Then If MsgBox("Aktuellen Prozess wirklich beenden?", _ MsgBoxStyle.Question Or MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
' Prozess-Objekt anhand Prozess-ID erstellen Dim oProccess As Process = Process.GetProcessById( _ Val(.SelectedItems(0).SubItems(2).Text))
Try ' Prozess beenden/zerstören oProccess.Kill() Catch ex As Exception ' Fehlermeldung... MsgBox("Fehler beim Beenden des Prozess." & vbCrLf & ex.Message.ToString) End Try End If End If End With End Sub[/code]
Quelle: vbarchiv.net _________________
cReative.pRoject Tutorial Leser
Anmeldedatum: 14.05.2008 Beiträge: 48
Verfasst am: 14.05.2008, 18:21
Fehler 1 Syntaxfehler. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 5 7 WindowsApplication1 Fehler 2 Eine Anweisung kann nicht innerhalb eines Methodentexts verwendet werden. Das Methodenende wird angenommen. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 9 7 WindowsApplication1 Fehler 3 Bezeichner erwartet. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 9 59 WindowsApplication1 Fehler 4 Syntaxfehler. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 11 9 WindowsApplication1 Fehler 5 Bezeichner erwartet. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 42 62 WindowsApplication1 Fehler 6 Syntaxfehler. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 44 9 WindowsApplication1 Fehler 7 "End Sub" muss ein entsprechendes "Sub" voranstehen. C:UserscReative.ExploiAppDataLocalTemporary ProjectsWindowsApplication1Form1.vb 85 5 WindowsApplication1
das kommt bei mir was is das für fehler? _________________
tr4st Überflieger
Anmeldedatum: 16.04.2008 Beiträge: 486
Verfasst am: 14.05.2008, 22:56
Poste bitte mal deinen Quellcode damit wir dir deine Fehler aufzeigen können, hast du den Quellcode 1:1 übernommen? Ein Syntax Fehler ist ja ein im groben ein "Rechtschreibfehler" daher nehme ich an das du etwas nicht richtig geschrieben hast bzw. Syntax Regeln nicht eingehalten hast.