var
Count: DWORD;
W: array[0..MAX_PATH -1] of WideChar;
begin
Count := GetConsoleTitleW(@W, SizeOf(W));
W[Count] := #0;
Writeln(string(W));
Readln;
end.
Unsafe. If the title length is longer than the buffer "W[Count] := #0" will mess up the program stack.