Убийство процесса

Программирование на Visual Basic, главный форум. Обсуждение тем программирования на VB 1—6.
Даже если вы плохо разбираетесь в VB и программировании вообще — тут вам помогут. В разумных пределах, конечно.
Правила форума
Темы, в которых будет сначала написано «что нужно сделать», а затем просьба «помогите», будут закрыты.
Читайте требования к создаваемым темам.
Cellard
Новичок
Новичок
 
Сообщения: 49
Зарегистрирован: 15.10.2002 (Вт) 22:10
Откуда: Russia

Убийство процесса

Сообщение Cellard » 29.01.2004 (Чт) 18:18

Знаю-знаю, тему сто раз поднимали.
Не говорите мне про API TerminateProcess или типа того - уже знаю.
Но что толку, как не мог прибить процесс зная PID, так и не могу... Помогите, дайте листинг прогрммки. Так чтоб "вставить и ехать".
(Все, с чем сталкивался прежде, приводило к разным интерсным результатам, но не к снятию процесса...)

Как альтернатива первому вопросу вопрос второй:
Зная PID, послать в программу нажатие клавиши. Как?
Cellard

Kostyan
Постоялец
Постоялец
 
Сообщения: 439
Зарегистрирован: 20.09.2002 (Пт) 4:14
Откуда: Россия, Уссурийск

Сообщение Kostyan » 30.01.2004 (Пт) 1:34

Убийство процесса зная его ID:
Call TerminateProcess(OpenProcess(H1F0FFF, ByVal 0, ProcessID), 0)
Нет ничего невозможного для человека с интеллектом.

v-adix
Постоялец
Постоялец
 
Сообщения: 490
Зарегистрирован: 14.11.2002 (Чт) 15:11

Сообщение v-adix » 30.01.2004 (Пт) 16:37

никто не знает как определить ID процесса заная имя exe-шки?

Cellard
Новичок
Новичок
 
Сообщения: 49
Зарегистрирован: 15.10.2002 (Вт) 22:10
Откуда: Russia

Сообщение Cellard » 30.01.2004 (Пт) 18:10

2 Kostyan
Call TerminateProcess(OpenProcess(H1F0FFF, ByVal 0, ProcessID), 0)


Растолкуй, что есть OpenProcess
Cellard

SVL
Обычный пользователь
Обычный пользователь
 
Сообщения: 97
Зарегистрирован: 19.12.2002 (Чт) 11:37
Откуда: Russia

Сообщение SVL » 30.01.2004 (Пт) 18:16

OpenProcess
The OpenProcess function returns a handle to an existing process object.

HANDLE OpenProcess(
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier
);

Parameters
dwDesiredAccess
Specifies the access to the process object. For operating systems that support security checking, this access is checked against any security descriptor for the target process. Any combination of the following access flags can be specified in addition to the STANDARD_RIGHTS_REQUIRED access flags: Access Description
PROCESS_ALL_ACCESS Specifies all possible access flags for the process object.
PROCESS_CREATE_PROCESS Used internally.
PROCESS_CREATE_THREAD Enables using the process handle in the CreateRemoteThread function to create a thread in the process.
PROCESS_DUP_HANDLE Enables using the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle.
PROCESS_QUERY_INFORMATION Enables using the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object.
PROCESS_SET_INFORMATION Enables using the process handle in the SetPriorityClass function to set the priority class of the process.
PROCESS_TERMINATE Enables using the process handle in the TerminateProcess function to terminate the process.
PROCESS_VM_OPERATION Enables using the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process.
PROCESS_VM_READ Enables using the process handle in the ReadProcessMemory function to read from the virtual memory of the process.
PROCESS_VM_WRITE Enables using the process handle in the WriteProcessMemory function to write to the virtual memory of the process.
SYNCHRONIZE Windows NT: Enables using the process handle in any of the wait functions to wait for the process to terminate.


bInheritHandle
Specifies whether the returned handle can be inherited by a new process created by the current process. If TRUE, the handle is inheritable.
dwProcessId
Specifies the process identifier of the process to open.
Return Values
If the function succeeds, the return value is an open handle to the specified process.

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

В VB определяется так:
Код: Выделить всё
Public Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

v-adix
Постоялец
Постоялец
 
Сообщения: 490
Зарегистрирован: 14.11.2002 (Чт) 15:11

Сообщение v-adix » 30.01.2004 (Пт) 18:22

а как ID определить по имени файла?

Cellard
Новичок
Новичок
 
Сообщения: 49
Зарегистрирован: 15.10.2002 (Вт) 22:10
Откуда: Russia

Сообщение Cellard » 30.01.2004 (Пт) 18:33

Спасибо, все работает
Cellard


Вернуться в Visual Basic 1–6

Кто сейчас на конференции

Сейчас этот форум просматривают: AhrefsBot, Yandex-бот и гости: 6

    TopList  
cron