title: How to check if process is suspended?
body: <p>Following code does not compile because my Delphi 7 complains about undeclared identifier <strong>PSYSTEM_THREAD = ^SYSTEM_THREAD</strong>. What UNIT am I missing from USES clause? ......................................................................................................................................................</p>
  <pre><code>unit Unit1;
  
  interface
  
  uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls;
  
  
  
  
  type
    TForm1 = class(TForm)
    Button1: TButton;
  
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  type
    PSYSTEM_THREAD = ^SYSTEM_THREAD
  
  
  var
    Form1: TForm1;
  
  function NtQuerySystemInformation(SystemInformationClass:DWORD; SystemInformation:pointer; SystemInformationLength:DWORD; ReturnLength:PDWORD):cardinal; stdcall; external 'ntdll';
  
  implementation
  
  {$R *.dfm}
  
  function IsThreadSuspended:Boolean;
  var spi:PSYSTEM_PROCESS_INFORMATION;
      crt:PSYSTEM_PROCESS_INFORMATION;
      PThreadInfo:PSYSTEM_THREAD;
      Size:DWORD;
     j:Integer;
     LastProcess:Boolean;
  begin
    Result:=False; // Default result, will be also returned if any error arises.
    // If process ID is 0 then we use current process ID
    If AProcessID=0 then AProcessID:=GetCurrentProcessId;
  
    if (NtQuerySystemInformation(5,nil,0,@Size)=STATUS_INFO_LENGTH_MISMATCH) and (Size&gt;0) then
    begin
      GetMem(spi,Size);
      try
        if NtQuerySystemInformation(5,spi,Size,@Size)=0 then
        begin
  
          crt:=spi;
          LastProcess:=False;
          While not LastProcess do
          begin
            LastProcess:=crt^.NextEntryOffset = 0;
            if crt^.ProcessID=AProcessID then
            begin
  
              for j := 0 to crt^.NumberOfThreads-1 do
              begin
                PThreadInfo:=PSYSTEM_THREAD(@crt^.ThreadInfo[j]);
                if PThreadInfo^.UniqueThread = AThreadID then
                begin
                  if PThreadInfo^.WaitReason = 5 then Exit(True) // the thread is suspended
                  else Exit(False); // the thread is not suspended
                  Break;
                end;
              end;
  
              Break;
            end;
            crt := Pointer(DWORD(crt) + crt^.NextEntryOffset);
          end;
  
         end else Exit; // failed listing processes!
       finally
          FreeMem(spi);
     end;
   end 
  else Exit; // failed listing processes!
  end;
  
  end.
  </code></pre>