Старый 23.04.2004, 10:44   #1   
Модератор
 
Сообщений: 665
Регистрация: 09.01.2002

Kerish вне форума Не в сети
Как снять процесс в XP?

Как осуществить через код.
Может кто сталкивался?
Можете дать пример на любом языке программирования. (Кроме Ассемблера).
 
Старый 23.04.2004, 14:56   #2   
Форумец
 
Сообщений: 1,696
Регистрация: 24.11.2002
Возраст: 39

LSL вне форума Не в сети
Kerish
Так можно закрыть программу по названию окна, а про процесс поищи тему, которую создавал fishca..

Код:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const WM_CLOSE = &H10
Public Const ProgName = "Название окна программы."

Private Sub CloseProgramm()
    Dim winHwnd As Long
    Dim RetVal As Long

    winHwnd = FindWindow(vbNullString, ProgName)

    If winHwnd <> 0 Then
        RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
        If RetVal = 0 Then MsgBox "Ошибка."
    Else
        MsgBox ProgName + " не открыт."
    End If
End Sub
 
Старый 23.04.2004, 15:18   #3   
Форумец
 
Аватар для fishca
 
Сообщений: 708
Регистрация: 23.12.2002
Возраст: 50
Записей в дневнике: 1

fishca вне форума Не в сети
Kerish
TerminateProcess - тебе поможет:

The TerminateProcess function terminates the specified process and all of its threads.

BOOL TerminateProcess(

HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);


Parameters

hProcess

Identifies the process to terminate.
Windows NT: The handle must have PROCESS_TERMINATE access. For more information, see Process Objects.

uExitCode

Specifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess
function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating.

Terminating a process causes the following:

1. All of the object handles opened by the process are closed.
2. All of the threads in the process terminate their execution.
3. The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate.
4. The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate.
5. The termination status of the process changes from STILL_ACTIVE to the exit value of the process.



Terminating a process does not cause child processes to be terminated.
Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed.

See Also

ExitProcess, OpenProcess, GetExitCodeProcess, GetExitCodeThread
 
Старый 24.04.2004, 08:07   #4   
Модератор
 
Сообщений: 665
Регистрация: 09.01.2002

Kerish вне форума Не в сети
Спасибо
 
Поиск в теме: 



Быстрый переход:

  Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd. Перевод: zCarot
Support by DrIQ & Netwind