zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    SSH出现Connection refused错误
    Lisp经典算法
    Arch Linux下韩文重叠显示
    Vim在图形环境下全屏产生黑边
    Vim常用插件安装及配置方法
    Python中Scrapy框架元素选择器XPath的简单实例
    Manjaro下Steam无法启动
    GNOME禁用GDM中night-light功能
    Neovim中提示Error: Required vim compiled with +python
    Manjaro下带供电的USB Hub提示error -71
  • 原文地址:https://www.cnblogs.com/hebeiDGL/p/2684658.html
Copyright © 2011-2022 走看看