WinAPI:GetUserName
//声明:
get username(
LP buffer:pchar;{ buffer }
var nSize:DWORD { buffer size }
):BOOL;
//示例:
var
arr: array [0..254]的char
d:DWORD;
begin
d:= SizeOf(arr);
GetUserName(arr,d);
show message(arr);{ wy }
end;
//再比如:
var
p:PChar;
num:DWORD;
begin
num:= 0;
GetUserName(nil,num);
show message(IntToStr(num));
GetMem(p,num);
GetUserName(p,num);
show message(p);{ wy }
FreeMem(p);
end;
//再比如:
var
p:PChar;
num:DWORD;
begin
num:= 0;
GetUserName(nil,num);
p:= StrAlloc(num);
if getusername (p,num)then
show message(p){ wy }
else show message(' none ');
StrDispose(p);
end;
0条评论