//聲明:
GetUserName(
lpBuffer: PChar; {緩沖區}
var nSize: DWORD {緩沖區大小}
): BOOL;
//舉例:
var
arr: array[0..254] of Char;
d: DWORD;
begin
d := SizeOf(arr);
GetUserName(arr, d);
ShowMessage(arr); {wy}
end;
//另一例:
var
p: PChar;
num: DWORD;
begin
num := 0;
GetUserName(nil, num);
ShowMessage(IntToStr(num));
GetMem(p, num);
GetUserName(p, num);
ShowMessage(p); {wy}
FreeMem(p);
end;
//再一例:
var
p: PChar;
num: DWORD;
begin
num := 0;
GetUserName(nil, num);
p := StrAlloc(num);
if GetUserName(p,num) then
ShowMessage(p) {wy}
else ShowMessage('無');
StrDispose(p);
end;