On Windows it should be USERNAME so you would still need to do IFDEFs.
Ok, I have not done much WinAPI programming.
However I found a function for Lazarus IDE's internal use, in unit ide/IDEProcs :
function GetCurrentUserName: string;
begin
Result:=GetEnvironmentVariableUTF8('USER');
end;
GetEnvironmentVariableUTF8 is just a wrapper for GetEnvironmentVariableWide (Windows) or GetEnvironmentVariable (other systems).
GetCurrentUserName is used for inserting your name in editor from menu : Source -> Insert General -> Current Username
Can you please test if it works on Windows. My guess is that recent Windows versions have 'USER' as an alternative env.variable. If not, then we have a bug and must add IFDEFs to the function.