Deklaration: Declare Function CreateToolhelp32Snapshot Lib "kernel32.dll" ( _ ByVal dwFlags As Long, _ ByVal th32ProcessID As Long) As Long Beschreibung: Parameter:
dwFlags Konstanten: ' Erzeugt einen vererbbaren Snapshot Const TH32CS_INHERIT = &H80000000 ' Erzeugt einen Snapshot aller Ressourcen Const TH32CS_SNAPALL = &HF ' Erzeugt zusätzlich einen Snapshot von Heaplisten Const TH32CS_SNAPHEAPLIST = &H1 ' Erzeugt zusätzlich einen Snapshot von Prozessen Const TH32CS_SNAPPROCESS = &H2 ' Erzeugt zusätzlich einen Snapshot von Threads Const TH32CS_SNAPTHREAD = &H4 ' Erzeugt zusätzlich einen Snapshot von Modulen Const TH32CS_SNAPMODULE = &H8 Rückgabewert: Beispiel: Private Declare Function CreateToolhelp32Snapshot Lib "kernel32.dll" ( _ ByVal dwFlags As Long, _ ByVal th32ProcessID As Long) As Long Private Declare Function Process32First Lib "kernel32.dll" ( _ ByVal hSnapshot As Long, _ lppe As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "kernel32.dll" ( _ ByVal hSnapshot As Long, _ lppe As PROCESSENTRY32) As Long Private Declare Function CloseHandle Lib "kernel32.dll" ( _ ByVal hObject As Long) As Long Private Declare Function lstrlen Lib "kernel32" _ Alias "lstrlenA" ( _ ByVal lpString As String) As Long Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type Private Const TH32CS_INHERIT = &H80000000 Private Const TH32CS_SNAPALL = &HF Private Const TH32CS_SNAPHEAPLIST = &H1 Private Const TH32CS_SNAPPROCESS = &H2 Private Const TH32CS_SNAPTHREAD = &H4 Private Const TH32CS_SNAPMODULE = &H8 ' alle laufenden Prozesse ermitteln Private Sub Command1_Click() Dim Retval As Long Dim hSnap As Long Dim PInfo As PROCESSENTRY32 ' Snapshot vom gesamten System erstellen hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) If hSnap = -1 Then MsgBox "Der System-Snapshot konnte nicht erstellt werden.", _ vbInformation, "Fehler" Exit Sub End If PInfo.dwSize = Len(PInfo) Retval = Process32First(hSnap, PInfo) ' ersten Prozess ermitteln List1.Clear Do Until Retval = 0 With PInfo .szExeFile = Trim$(Left$(.szExeFile, lstrlen(.szExeFile))) _ ' VBNullChar abtrennen List1.AddItem "# " & Format$(Abs(.th32ProcessID), "00000000") & " - _ " & Mid$(.szExeFile, InStrRev(.szExeFile, "\") + 1) End With Retval = Process32Next(hSnap, PInfo) ' nächsten Prozess ermitteln DoEvents Loop CloseHandle hSnap ' Snapshot zerstören End Sub Diese Seite wurde bereits 14.267 mal aufgerufen. |
Neu! sevCoolbar 3.0 Professionelle Toolbars im modernen Design! Mit sevCoolbar erstellen Sie in wenigen Minuten ansprechende und moderne Toolbars und passen diese optimal an das Layout Ihrer Anwendung an (inkl. große Symbolbibliothek) - für VB und MS-Access Buchempfehlung Tipp des Monats April 2024 Skyfloy Chart von Microsoft und dazu noch gratis Tutorial für Microsoft Chart Controls für Microsoft .NET Framework 3.5 TOP Entwickler-Paket TOP-Preis!! Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR... |
||||||||||||||
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. |