Ja sam to ovako resio:
Code:
function CommaStr (Position: integer; CommaChar: char; const st: string): string;
var i, b, e, n: integer;
begin
i := 1;
b := 0;
n := 1;
e := Length (st);
while i <= Length (st) do
begin
if st[i] = CommaChar then
if Position = n then
begin
e := i - 1;
break;
end
else
begin
b := i;
n := n + 1;
end;
i := i + 1;
end;
Result := Copy (st, b + 1, e - b);
end;
function GetUserName: string;
var passfile: TextFile;
s: string;
uid: integer;
begin
AssignFile(passfile, '/etc/passwd');
Reset(passfile);
Result := '';
uid := getuid;
while not eof(passfile) do
begin
readln (passfile, s);
if StrToIntDef(CommaStr(3, ':', s), -1) = uid then
begin
Result := CommaStr(1, ':', s);
break;
end;
end;
CloseFile(passfile);
end;
Trebalo bi samo da ukljucis
Libc u uses sekciju.
Pozdrav