AW: API-Zugriff
21.03.2007 23:09:00
Nepumuk
Hallo Host,
das frag ich mich auch, aber gehen tut's so:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
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, _
ByRef lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32.dll" ( _
ByVal hSnapshot As Long, _
ByRef lppe As PROCESSENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As Long) As Long
Private Const TH32CS_SNAPPROCESS = &H2
Private Const MAX_PATH = 260
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 * MAX_PATH
End Type
Public Sub Alle_Prozesse()
Dim Snap As Long, Result As Long
Dim Process As PROCESSENTRY32
Snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If Snap <> -1 Then
Process.dwSize = Len(Process)
Result = Process32First(Snap, Process)
Do Until Result = 0
If InStr(1, LCase$(Process.szExeFile), "winword.exe") Then
MsgBox "Word läuft PID: " & CStr(Process.th32ProcessID)
Exit Do
End If
Result = Process32Next(Snap, Process)
Loop
End If
CloseHandle Snap
End Sub
Gruß
Nepumuk