title: Using GetUserName for multiple Windows versions and 32/64
body: <p>Is it possible to use the Win API function <code>GetUserName</code> for Windows XP through Windows 8? For both 32 and 64 bit?</p>
  
  <pre><code>function getUserName: String;
  var
    BufSize: DWord;
    Buffer: PWideChar;
  begin
   BufSize:= 1024;
   Buffer:= AllocMem(BufSize);
   try
    if GetUserName(Buffer, BufSize) then
        SetString(result, Buffer, BufSize)
   else
    RaiseLastOSError;
   finally
    FreeMem(Buffer);
   end;
  end;
  </code></pre>
  
  <p>thanx</p>