{$ifdef WINDOWS}uses Windows;{$endif}
{$ifdef UNIX}uses BaseUnix;{$endif}
{$ifdef UNIX}
function GetUserName: String;
begin
Result:=GetEnvironmentVariable('USER');
end;
{$endif}
{$ifdef WINDOWS}
function GetUserName: String;
var pszName: PChar;
nSize : DWord;
begin
nSize:=100;
pszName:=StrAlloc(nSize);
Windows.GetUserName(pszName,nSize);
Result:=StrPas(pszName);
StrDispose(pszName);
end;
{$endif}
{$ifdef UNIX}
function GetComputerName: String;
var aUtsName: UtsName;
begin
Result:='';
aUtsName.Nodename[0]:=#0; // This is just for suppressing the compiler warning.
FillChar(aUtsName,SizeOf(aUtsName),0);
if FpUname(aUtsName)<>-1 then
begin
Result:=aUtsName.Nodename;
end;
end;
{$endif}
{$ifdef WINDOWS}
function GetComputerName: String;
var aBuf: Array[0..255] of Char;
bRet: Boolean;
nSize: DWord;
begin
aBuf[0]:=#0;
nSize:=SizeOf(aBuf);
bRet:=Windows.GetComputerName(aBuf,nSize);
aBuf[SizeOf(aBuf)-1]:=#0; // Just for safety reasons
Result:=Trim(aBuf);
end;
{$endif}