Windows call
Var
Buffer: array[0..1023] of char;
begin
Result := windows.GetTempPath (SizeOf(Buffer), Buffer));
end;
Since unicode chars are two bytes instead of one, the result of SizeOf is twice as long as expected.
Solve by using length, which results in the number of characters, not bytes.
Result := windows.GetTempPath(length(Buffer), Buffer));