- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 取Windows登录用户名
//取本机的计算机名
{ ComputerName }
function ComputerName: string;
var
FStr: PChar;
FSize: Cardinal;
begin
FSize := 255;
GetMem(FStr, FSize);
Windows.GetComputerName(FStr, FSize);
Result := FStr;
FreeMem(FStr);
end;
//取Windows登录用户名
{ WinUserName }
function WinUserName: string;
var
FStr: PChar;
FSize: Cardinal;
begin
FSize := 255;
GetMem(FStr, FSize);
GetUserName(FStr, FSize);
Result := FStr;
FreeMem(FStr);
end;