program Processlist;

uses MySQL;

var
  MHandle: PMySQL;
  Passwd: String (100);
  MRes: PMySQLRes;
  NumRows, i: LongCard;
  NumFields, j: Cardinal;
  MRow: PMySQLRow;

begin
  MHandle := MySQLInit (nil);
  Write ('Please enter MySQL-Root Password: ');
  ReadLn (Passwd);
  if MySQLRealConnect (MHandle, 'localhost', 'root', Passwd, '', 0, nil, 0) = nil then
    begin
      WriteLn (StdErr, 'Cannot connect to MySQL Server');
      WriteLn (StdErr, 'Error Code ', MySQLError (MHandle))
    end
  else
    begin
      MRes := MySQLListProcesses (MHandle);
      NumRows := MySQLNumRows (MRes);
      NumFields := MySQLNumFields (MRes);
      for i := 0 to NumRows - 1 do
        begin
          MRow := MySQLFetchRow (MRes);
          for j := 0 to NumFields - 1 do
            Write (CString2String (MRow^[j]), ', ');
          WriteLn
        end;
      MySQLFreeResult (MRes);
      MySQLClose (MHandle)
    end
end.
