[Lazarus] real user name

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Jan 14 13:54:20 CET 2009


2009/1/14 Reenen Laurie <rlaurie at gmail.com>:
>
> {$ifdef windows}
>   username := GetEnvironmentVariable('USERNAME');
> {$endif}

Nope, change that to something like:

var
  userNameBuffer: array[0..255] of char;
  sizeBuffer: DWord;
begin
  SizeBuffer := 256;
  getUserName(userNameBuffer, sizeBuffer);
  result := string(userNameBuffer);


> {$ifdef linux}
>   GetUserData(FpGetuid, Data);
>   username := Data.pw_uid;
> {$endif}
>
> How about MacOS?

Change that to {$ifdef unix} instead.


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the Lazarus mailing list