Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Maza Faka

Ветеран


Сообщения: 604
Благодарности: 133

Профиль | Отправить PM | Цитировать


Creat0R
Привет! Не поможешь?
Никак не получается убить процесс средствами WinAPI

Код: Выделить весь код
#include <Array.au3>

Process_Kill("totalcmd.exe")

Func Process_Kill($sProc)
    Local $ProcHandle
    Local $ProcessPid = ProcessExists($sProc)
    If $ProcessPid = 0 Then
        MsgBox(16, "Error", "Process " & $sProc & " not exist")
        Return SetError(1)
    EndIf

    $ProcHandle = DllCall("kernel32.dll", "hwnd", "OpenProcess", "dword", BitOR(0x0400, 0x0004), "int", 0, "dword", $ProcessPid)

    If $ProcHandle[0] = 0 Then
        MsgBox(16, "Error", "Process " & $sProc & " not exist")
        Return SetError(1)
    EndIf

    $ProcHandle = $ProcHandle[0]

    $ProcTerminate = DllCall("kernel32.dll", "int", "TerminateProcess", "hwnd", $ProcHandle, "uint", "?")

    $CloseHandle = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $ProcHandle)
    ConsoleWrite("@@ (6) : " & $CloseHandle[0] & "       ")
EndFunc
В выделенной строке в место параметра "?", надо вставить
Цитата:
uExitCode

The exit code to be used by the process and threads terminated as a result of this call. Use the GetExitCodeProcess [ http://msdn2.microsoft.com/en-us/lib...,printer).aspx ] function to retrieve a process's exit value. Use the GetExitCodeThread [ http://msdn2.microsoft.com/en-us/lib...,printer).aspx ] function to retrieve a thread's exit value.
Цитата:
GetExitCodeProcess Function


Retrieves the termination status of the specified process.
BOOL WINAPI GetExitCodeProcess(
__in HANDLE hProcess,
__out LPDWORD lpExitCode
);
Parameters
hProcess

A handle to the process.

The handle must have the PROCESS_QUERY_INFORMATION access right. For more information, see Process Security and Access Rights [ http://msdn2.microsoft.com/en-us/lib...,printer).aspx ] .
lpExitCode

A pointer to a variable to receive the process termination status. If the specified process has not terminated and the function succeeds, the status is STILL_ACTIVE.
Как я понял нужно создать структуру Dll, а вот как её создать?

Отправлено: 09:31, 27-12-2007 | #912