uses
SysUtils, Classes, Process, Windows;
procedure TForm1.Button1Click(Sender: TObject);
var
Stockfish: TProcess;
Output: TStringList;
Command: string;
Line: string;
Buffer: array[0..255] of AnsiChar;
BytesRead: Cardinal;
begin
// Stockfish uygulamasının yolu
Command := 'C:\path\to\stockfish.exe'; // Stockfish'in tam yolu
// Çıktıyı almak için bir TStringList oluştur
Output := TStringList.Create;
try
// Stockfish'i başlat
Stockfish := TProcess.Create(nil);
try
Stockfish.Executable := Command;
Stockfish.Options := Stockfish.Options + [poUsePipes];
Stockfish.Start;
// Hamleyi gönder
Stockfish.Input.Write(PAnsiChar(AnsiString('position startpos moves ' + Edit1.Text + #13#10)), Length('position startpos moves ' + Edit1.Text + #13#10));
Stockfish.Input.Write(PAnsiChar(AnsiString('go' + #13#10)), Length('go' + #13#10));
// Çıktıyı oku
while not Stockfish.Output.Eof do
begin
BytesRead := Stockfish.Output.Read(Buffer, SizeOf(Buffer));
SetString(Line, Buffer, BytesRead);
Output.Add(Line);
end;
// Çıktıyı Memo1'e yazdır
Memo1.Lines.AddStrings(Output);
finally
Stockfish.Free;
end;
finally
Output.Free;
end;
end;