procedure TForm1.Button1Click(Sender: TObject);<br>var<br> pcUser : PChar;<br> dwUSize : DWORD;<br>begin<br> dwUSize := 21; // user name can be up to 20 characters<br> GetMem( pcUser, dwUSize ); // allocate memory for the string<br> try<br> if Windows.GetUserName( pcUser, dwUSize ) then<br> edit1.Text := pcUser<br> finally<br> FreeMem( pcUser ); // now free the memory allocated for the string<br> end;<br>end;<br>