获取本机计算机名及登录的用户名

 
//获取计算机名
{
	TCHAR Name_buffer[MAX_COMPUTERNAME_LENGTH + 1] = {0};
	DWORD size = sizeof(Name_buffer);
	if(GetComputerName(Name_buffer,&size))
	{
		//成功获取
	}
	else
	{
		err = GetLastError();
	}
}

//获取登录用户名
{
	TCHAR userName[UNLEN + 1] = {0};
	size = sizeof(userName);
	if(GetUserName(userName,&size))
	{
		//成功获取
	}
	else
	{
		err = GetLastError();		
	}
}
<PRE></PRE>

你可能感兴趣的:(buffer)