- Код: Выделить всё
...
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode 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
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
...
Sub CloseExplorer()
Dim hwnd As Long
Dim pid As Long
Dim hproc As Long
Dim ecode As Long
hwnd = FindWindow("Shell_traywnd", "")
If Not hwnd = 0 Then
GetWindowThreadProcessId hwnd, pid
hproc = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
GetExitCodeProcess hproc, ecode
TerminateProcess hproc, ecode
CloseHandle hproc
End If
End Sub
Так вот CloseExplorer выгружает только на секунд 10. Как-то же Диспечер задач выгружает его нормально? Но как? В чём ошибка?