Problem: Ich habe ein "externes" (ich hab's nicht geschrieben) Programm, das immer außer sonntags starten soll. Folgender Code:
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As _
Long, lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As _
Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Function ShellX(ByVal PathName As String, Optional ByVal WindowStyle As _
VbAppWinStyle = vbMinimizedFocus, Optional ByVal Events As Boolean = True) As _
Long
'Deklarationen:
Const STILL_ACTIVE = &H103&
Const PROCESS_QUERY_INFORMATION = &H400&
Dim ProcId As Long
Dim ProcHnd As Long
'Prozess-Handle holen:
ProcId = Shell(PathName, WindowStyle)
ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId)
'Auf Prozess-Ende warten:
Do
If Events Then DoEvents
GetExitCodeProcess ProcHnd, ShellX
Loop While ShellX = STILL_ACTIVE
'Aufräumen:
CloseHandle ProcHnd
End Function
Private Sub Form_Load()
If Weekday(Now) <> 1 Then
ShellX "soc.exe", vbNormalFocus
End If
Unload Me
End Sub Die Function ShellX ist nur da, um die Startdatei (soc.exe) des externen Programms zu starten.Problem: Ich habe ein "externes" (ich hab's nicht geschrieben) Programm, das immer außer sonntags starten soll. Folgender Code:
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As _
Long, lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As _
Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Function ShellX(ByVal PathName As String, Optional ByVal WindowStyle As _
VbAppWinStyle = vbMinimizedFocus, Optional ByVal Events As Boolean = True) As _
Long
'Deklarationen:
Const STILL_ACTIVE = &H103&
Const PROCESS_QUERY_INFORMATION = &H400&
Dim ProcId As Long
Dim ProcHnd As Long
'Prozess-Handle holen:
ProcId = Shell(PathName, WindowStyle)
ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId)
'Auf Prozess-Ende warten:
Do
If Events Then DoEvents
GetExitCodeProcess ProcHnd, ShellX
Loop While ShellX = STILL_ACTIVE
'Aufräumen:
CloseHandle ProcHnd
End Function
Private Sub Form_Load()
If Weekday(Now) <> 1 Then
ShellX "soc.exe", vbNormalFocus
End If
Unload Me
End Sub Die Function ShellX ist nur da, um die Startdatei (soc.exe) des externen Programms zu starten.
Wenn nun Sonntag ist, ist alles in Ordnung: Das externe Programm wird nicht gestartet und mein gemachtes kleines Programm unloaded wieder.
Aber an einem Wochentag: Das externe Programm wird gestartet aber mein gemachtest Programm bleibt im Win Taskmanager und macht eine Prozessorauslastung von 100%. Warum wird "Unload Me" denn bloß ignoriert und warum ausgerechnet soviel Auslastung?!
---------------------------------------
City4ALL- die erste, virtuelle 3D Stadt im Internet! Infos unter www.3DWelt.tk |