(***********************************************)
(*                                             *)
(* Win32 Process Viewer Application            *)
(* Copyright (c) 1999 by TMT Development Corp. *)
(* Author: Vadim Bodrov, TMT Development Corp. *)
(*                                             *)
(* Targets:                                    *)
(*   Win32 only                                *)
(*                                             *)
(***********************************************)

program PView;

{$ifndef __WIN32__}
  This program must be compiled as Win32 application only
{$endif}

uses Strings, Windows, TLHelp32 {$ifdef __GUI__}, WinCRT {$endif};
var
  hSnapShot: THandle;
  uProcess: TProcessEntry32;
  r: Boolean;
begin
 Writeln('PView for Win32.');
 Writeln('Copyright (c) 1999 by TMT Development Corp.');
 Writeln('---------  --------------------------');
 Writeln('   PID     PROCESS NAME [THREAD CNT.]');
 Writeln('---------  --------------------------');
 hSnapShot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 If hSnapShot <> 0 Then
 begin
   uProcess.dwSize := SizeOf(uProcess);
   r := Process32First(hSnapShot, uProcess);
   While r do
   begin
     Writeln(Hex(uProcess.th32ProcessID) + 'h  ' +
             StrPas(uProcess.szExeFile) +
             ' [' + IntToStr(uProcess.CntThreads) + ']');
     r := Process32Next(hSnapShot, uProcess);
   end;
   CloseHandle(hSnapShot);
  end;
end.
