1,183
社区成员
发帖
与我相关
我的任务
分享
// 取得当前登录用户名称
function getCurrentUserName : string;
const
cnMaxUserNameLen = 255;
var
strUserName : string;
dwUserNameLen : DWORD;
begin
dwUserNameLen := cnMaxUserNameLen-1;
SetLength(strUserName, cnMaxUserNameLen);
GetUserName(Pchar(strUserName), dwUserNameLen);
SetLength(strUserName, dwUserNameLen );
Result := strUserName;
end;
//获取PC机的机器名称
function getPCName(var aName: string): Boolean;
var
size: DWord;
localMachine: array [0..MAX_COMPUTERNAME_LENGTH] of char;
begin
size := Sizeof(LocalMachine);
if GetComputerName(localMachine, size) then
begin
aName := localMachine;
Result := True;
end
else Result := False;
end;