01、获取计算机用户的信息

 引用命名空间: using Windows.System.UserProfile; 

1、获取用户头像信息:

  

            // The small picture returned by GetAccountPicture() is 96x96 pixels in size.
            StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.SmallImage) as StorageFile;
            if (image != null)
            {
try
                {
                    IRandomAccessStream imageStream = await image.OpenReadAsync();
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.SetSource(imageStream);
                    smallImage.Source = bitmapImage;
                }
                catch (Exception ex)
                {
                    
} }

 获取大头像只需把第一句改为:

  // The large picture returned by GetAccountPicture() is 448x448 pixels in size.
  StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.LargeImage) as StorageFile;

获取用户的 mp4 用户视频:

// The video returned from getAccountPicture is 448x448 pixels in size.
            StorageFile video = UserInformation.GetAccountPicture(AccountPictureKind.Video) as StorageFile;
            if (video != null)
            {
try
                {
                    IRandomAccessStream videoStream = await video.OpenAsync(FileAccessMode.Read);

                    mediaPlayer.SetSource(videoStream, "video/mp4");
                    mediaPlayer.Visibility = Visibility.Visible;
                }
                catch (Exception ex)
                {
                   
} }

 2、获取当前用户名:

 string displayName = await UserInformation.GetDisplayNameAsync();

用户的 FirstName:

 string firstName = await UserInformation.GetFirstNameAsync();

用户的 LastName:

 string lastName = await UserInformation.GetLastNameAsync();
原文地址:https://www.cnblogs.com/hebeiDGL/p/2684658.html