Check and kill task (XP, 98) NO NT.

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Registry,StdCtrls, ExtCtrls, ComCtrls, jpeg, Buttons,TlHelp32,TrayIcon, Psapi,ShellApi,

 

var

  Form1: TForm1;

  proc : PROCESSENTRY32;

  hSnap : HWND;

  Looper : BOOL;

 

 

 procedure CreateWin9xProcessList(List: TstringList);

var

  hSnapShot: THandle;

  ProcInfo: TProcessEntry32;

begin

  if List = nil then Exit;

  hSnapShot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);

  if (hSnapShot <> THandle(-1)) then

  begin

    ProcInfo.dwSize := SizeOf(ProcInfo);

    if (Process32First(hSnapshot, ProcInfo)) then

    begin

      List.Add(ProcInfo.szExeFile);

      while (Process32Next(hSnapShot, ProcInfo)) do

        List.Add(ProcInfo.szExeFile);

    end;

    CloseHandle(hSnapShot);

  end;

end;

 

procedure CreateWinNTProcessList(List: TstringList);

var

  PIDArray: array [0..1023] of DWORD;

  cb: DWORD;

  I: Integer;

  ProcCount: Integer;

  hMod: HMODULE;

  hProcess: THandle;

  ModuleName: array [0..300] of Char;

begin

  if List = nil then Exit;

  EnumProcesses(@PIDArray, SizeOf(PIDArray), cb);

  ProcCount := cb div SizeOf(DWORD);

  for I := 0 to ProcCount - 1 do

  begin

    hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or

      PROCESS_VM_READ,

      False,

      PIDArray[I]);

    if (hProcess <> 0) then

    begin

      EnumProcessModules(hProcess, @hMod, SizeOf(hMod), cb);

      GetModuleFilenameEx(hProcess, hMod, ModuleName, SizeOf(ModuleName));

      List.Add(ModuleName);

      CloseHandle(hProcess);

    end;

  end;

end;

 

procedure GetProcessList(var List: TstringList);

var

  ovi: TOSVersionInfo;

begin

  if List = nil then Exit;

  ovi.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);

  GetVersionEx(ovi);

  case ovi.dwPlatformId of

    VER_PLATFORM_WIN32_WINDOWS: CreateWin9xProcessList(List);

    VER_PLATFORM_WIN32_NT: CreateWinNTProcessList(List);

  end

end;

 

function EXE_Running(FileName: string; bFullpath: Boolean): Boolean;

var

  i: Integer;

  MyProcList: TstringList;

begin

  MyProcList := TStringList.Create;

  try

    GetProcessList(MyProcList);

    Result := False;

    if MyProcList = nil then Exit;

    for i := 0 to MyProcList.Count - 1 do

    begin

      if not bFullpath then

      begin

        if CompareText(ExtractFileName(MyProcList.Strings[i]), FileName) = 0 then

          Result := True

      end

      else if CompareText(MyProcList.strings[i], FileName) = 0 then Result := True;

      if Result then Break;

    end;

  finally

    MyProcList.Free;

  end;

end;

 

procedure KillProcess(SelectedProcess : String);

begin

 //Gets Selected String In The ListBox

proc.dwSize := SizeOf(Proc); //Give Proc.dwSize The Size Of Its Bytes

hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);  //Takes A Snapshop Of The Process And Give It To hSnap

Looper := Process32First(hSnap,proc);  //Gets The First Process

while Integer(Looper) <> 0 do //If The Process is not nil

begin

if UpperCase(ExtractFileName(Proc.szExeFile)) = UpperCase(SelectedProcess) then //Extracts the process filename and commpares with the selected string in the list box if true it carrys on

if TerminateProcess(OpenProcess(PROCESS_TERMINATE,Bool(1),proc.th32ProcessID),0) then  //Terminates the OpenProcess

//application.MessageBox('Dostęp do tego programu został zablokowany, skontaktuj się z administratorem.','Nie można uruchomić programu',mb_iconasterisk)

else

MessageBox(0,'Program nie działa poprawnie na tym komputerze.','Error',MB_OK); //I Never Seen A Error I Even Killed The Kernal Which Is The Source Of Memmory Which Killed This Project Unsave lol

Looper := Process32Next(hSnap,proc); //Checks for the next process its just like the GetNextWindow Function eheh I prefer The EnumWindows function though :)

end;

CloseHandle(hSnap); //Closes The Handle

end;