Location: Symbol Reference > Classes > TJwWTSProcessList Class > TJwWTSProcessList Methods > TJwWTSProcessList.GetEnumerator Method
JWSCL Documentation
ContentsIndexHome
PreviousUpNext
TJwWTSProcessList.GetEnumerator Method
Pascal
function GetEnumerator: TJwProcessEnumerator;

GetEnumerator returns an enumerator that can be used to iterate through the image list collection with Delphi's for in loop (Delphi 2005 and higher). 

 

var
  ATerminalServer: TJwTerminalServer;
  Process: TJwWTSProcess;
begin
  // Create Terminal Server instance and allocate memory for it
  ATerminalServer := TJwTerminalServer.Create;

  // It's recommended to wrap the Connect call in a try..except block since
  // a connection failure will raise an exception.
  try
    ATerminalServer.Connect;
  except
    on E: EJwsclWinCallFailedException do
    begin
      // Handle Exception here
    end;
  end;

  // EnumerateProcesses might fail and return false, so always check the
  // result.
  if ATerminalServer.EnumerateProcesses then
  begin

    // Loop through the Processes with the for..in loop (needs Delphi 2005
    // or higher).
    for Process in ATerminalServer.Processes do
    begin
      Memo1.Lines.Add(Format('Process %s runs in  session %d with PID %d',
        [Process.Processname, Process.SessionId, Process.ProcessId]));
    end;

  end;

  // Free Memory (note that free will automatically disconnect an active
  // connection)

  ATerminalServer.Free;

end;
Copyright (c) 2010. All rights reserved.
This help was created by Doc-O-Matic sponsored by toolsfactory software inc.
What do you think about this topic? Send feedback!