Abfrage: Läuft Outlook Express?

Hallo zusammen,
wie kann ich mit VisualBasic 4 unter WinXP abfragen, ob Outlook Express 6 läuft?
Wie kann ich dieses starten, falls es noch nicht läuft - den absoluten Pfad zur msimn.exe kenne ich nicht…

Hi Tino !

Also unter VB6 (weiß nicht ob’s auch unter VB4 geht) würde ich Dir empfehlen über API-Calls auf die PSAPI.DLL die Prozesse auszulesen !

hier ein kleines Sample :

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As Long) As Long

Public Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, \_
 ByVal bInheritHandle As Long, \_
 ByVal dwProcId As Long) As Long

Public Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, \_
 ByVal cb As Long, \_
 ByRef cbNeeded As Long) As Long

Public Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, \_
 ByVal hModule As Long, \_
 ByVal ModuleName As String, \_
 ByVal nSize As Long) As Long

Public Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, \_
 ByRef lphModule As Long, \_
 ByVal cb As Long, \_
 ByRef cbNeeded As Long) As Long


'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

Type typUsrTabs
 usr As String
 tab As String
End Type

Public Type PROCESSENTRY32
 dwSize As Long
 cntUsage As Long
 th32ProcessID As Long ' This process
 th32DefaultHeapID As Long
 th32ModuleID As Long ' Associated exe
 cntThreads As Long
 th32ParentProcessID As Long ' This process's parent process
 pcPriClassBase As Long ' Base priority of process threads
 dwFlags As Long
 szExeFile As String \* 260 ' MAX\_PATH
End Type
'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Global gal\_PidAtStart() As Long
Global gb\_Start As Boolean
Global gb\_abbrechen As Boolean
Global gd\_StartZeit As Date
'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

Public Const PROCESS\_QUERY\_INFORMATION = 1024
Public Const PROCESS\_VM\_READ = 16
Public Const MAX\_PATH = 260
Public Const STANDARD\_RIGHTS\_REQUIRED = &HF0000
Public Const SYNCHRONIZE = &H100000
'STANDARD\_RIGHTS\_REQUIRED Or SYNCHRONIZE Or &HFFF
Public Const PROCESS\_ALL\_ACCESS = &H1F0FFF
Public Const TH32CS\_SNAPPROCESS = &H2&
Public Const hNull = 0


Sub Main()

 Form1.Show
 gb\_Start = True
 gb\_abbrechen = False
 gd\_StartZeit = Now
 If fb\_ProcessStarted Then
 gb\_Start = False
 Form1.tmr.Interval = 1000
 Else
 Call WeiterMachen
 End If
End Sub


Sub WeiterMachen()

 Form1.tmrWork.Interval = 1000


End Sub

Sub s\_Ende()

 Unload Form1
 End

End Sub

Function fb\_ProcessStarted() As Boolean

Dim ll\_cb As Long
Dim ll\_cbNeeded As Long
Dim ll\_NumElements As Long
Dim la\_ProcessIDs() As Long
Dim ll\_cbNeeded2 As Long
Dim ll\_NumElements2 As Long
Dim la\_Modules(1 To 200) As Long
Dim ll\_Ret As Long
Dim ls\_ModuleName As String
Dim ll\_Size As Long
Dim ll\_hProcess As Long
Dim ll\_idx As Long
Dim li\_Found As Integer

Dim lal\_Pids() As Long

 'On Error GoTo ErrHandler
 fb\_ProcessStarted = False

 ll\_cb = 8
 ll\_cbNeeded = 96
 Do While ll\_cb 0 Then
 'Get an array of the module handles for the specified process
 ll\_Ret = EnumProcessModules(ll\_hProcess, la\_Modules(1), 200, ll\_cbNeeded2)
 'If the Module Array is retrieved, Get the ModuleFileName
 If ll\_Ret 0 Then
 ls\_ModuleName = Space(MAX\_PATH)
 ll\_Size = 500
 ll\_Ret = GetModuleFileNameExA(ll\_hProcess, la\_Modules(1), ls\_ModuleName, ll\_Size)
 ls\_ModuleName = UCase(Left(ls\_ModuleName, ll\_Ret))
 ll\_Ret = CloseHandle(ll\_hProcess)

 If InStr(1, ls\_ModuleName, UCase(App.EXEName & ".exe")) \> 0 Then
 li\_Found = li\_Found + 1

 ReDim Preserve lal\_Pids(li\_Found) As Long
 lal\_Pids(li\_Found) = la\_ProcessIDs(ll\_idx)

 If gb\_Start Then
 ReDim Preserve gal\_PidAtStart(li\_Found) As Long
 gal\_PidAtStart(li\_Found) = la\_ProcessIDs(ll\_idx)
 End If

 End If

 End If
 End If
 'Close the handle to the process
 'll\_Ret = CloseHandle(ll\_hProcess)
 Next

Dim li\_idx As Integer

 If li\_Found \> 1 Then

 li\_Found = 0

 For ll\_idx = 1 To UBound(lal\_Pids)
 For li\_idx = 1 To UBound(gal\_PidAtStart)
 If gal\_PidAtStart(li\_idx) = lal\_Pids(ll\_idx) Then
 li\_Found = li\_Found + 1
 End If
 Next
 Next

 Form1.Text1 = li\_Found

 If li\_Found \> 1 Then
 fb\_ProcessStarted = True
 End If

 Else
 fb\_ProcessStarted = False
 End If

 Exit Function

ErrHandler:
 MsgBox ("Fehler : " & Err.Description)

End Function

Ciao
Mario