Delphi-Quellcode:
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function UserName: String;
var
Size: DWORD;
begin
Size := MAX_COMPUTERNAME_LENGTH + 1;
SetLength(Result, Size);
if GetUserName(PChar(Result), Size) then
SetLength(Result, Size)
else
Result := '';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption := UserName;
end;
Ein paar Grundlagentutorials / -bücher wären wohl nicht schlecht.