UserInformation 類別

定義

代表使用者的相關資訊,例如名稱和帳戶圖片。

重要

Windows 10或更新版本不支援 UserInformation 類別。 請改用 User 類別。 請參閱<備註>。

public ref class UserInformation abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.System.UserProfile.UserProfileContract, 65536)]
class UserInformation final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.System.UserProfile.UserProfileContract, 65536)]
/// [Windows.Foundation.Metadata.Deprecated("Use User instead of UserInformation. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 131072, "Windows.System.UserProfile.UserProfileContract")]
class UserInformation final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.System.UserProfile.UserProfileContract), 65536)]
public static class UserInformation
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.System.UserProfile.UserProfileContract), 65536)]
[Windows.Foundation.Metadata.Deprecated("Use User instead of UserInformation. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 131072, "Windows.System.UserProfile.UserProfileContract")]
public static class UserInformation
Public Class UserInformation
繼承
Object Platform::Object IInspectable UserInformation
屬性

Windows 需求

裝置系列
Windows Desktop Extension SDK (已於 10.0.10240.0 引進)
Windows Mobile Extension SDK (已於 10.0.10240.0 引進)
API contract
Windows.System.UserProfile.UserProfileContract (已於 v1.0 引進)

範例

function getUserInfo() {
    image = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.smallImage);
    imageURL = URL.createObjectURL(image, false);
}    

備註

重要

Windows 10或更新版本不支援 UserInformation 類別。 請改用 User 類別。

Windows 10針對使用 UserInformation 類別的 Windows 8 編譯的應用程式,在Windows 10上執行時,不再傳回使用者資訊。 這是因為在Windows 10中,應用程式在未明確同意的情況下無法存取使用者資訊,不同于預設授與此許可權的 Windows 8。

如果您有使用 UserInformation 類別的 Windows 8 應用程式,您應該將應用程式移轉至 通用 Windows 平臺 (UWP) ,並改為存取User類別。 通用 Windows 平臺 (存取使用者資訊的 UWP) app 現在應該宣告新功能 uap:userAccountInformation,並呼叫新的 API Windows.System.User.FindAllAsyncUser.GetPropertiesAsync來取得資料。

當使用者安裝應用程式時,系統會提示他們允許存取其使用者資訊。 如果使用者允許應用程式存取訊號,應用程式會出現在 [Windows 10設定UI] 的 [隱私權] 頁面中, ([設定>隱私權>帳戶] 資訊) 。 這可讓Windows 10使用者存取個別應用程式的使用者資訊。

您也可以藉由部署群組原則變更來啟用使用者資訊的存取權,而不需修改額外的程式碼,這對商務和企業客戶特別有用。 若要允許存取Windows 10的使用者資訊,請啟用下列群組原則設定,並將它設定為 「Always On」:電腦 > 設定系統管理範本 > 系統 > 使用者設定檔 使用者策略 > 檔:與應用程式共用使用者名稱、帳戶圖片和網域資訊與應用程式 (非桌面應用程式) 。 如需詳細資訊,請下載群組原則 Windows 和 Windows Server 的設定參考

Windows 8 若要在帳戶圖片模式中啟動,以及設定使用者的圖片而不提示,應用程式必須註冊為帳戶圖片提供者,方法是在應用程式資訊清單的 [ 延伸 模組] 區段中加入下列內容。

屬性

AccountPictureChangeEnabled

判斷是否可以變更使用者的帳戶圖片。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

NameAccessAllowed

可讓您查看應用程式是否允許存取使用者的資訊。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

方法

GetAccountPicture(AccountPictureKind)

取得使用者的帳戶圖片。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetDisplayNameAsync()

取得使用者帳戶的顯示名稱。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetDomainNameAsync()

取得使用者的功能變數名稱。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetFirstNameAsync()

取得使用者的名字。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetLastNameAsync()

取得使用者的姓氏。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetPrincipalNameAsync()

取得使用者的主體名稱。 此名稱是使用者主體名稱 (通常是使用者的位址,但這不是一定 true。)

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

GetSessionInitiationProtocolUriAsync()

取得使用者的會話初始通訊協定的統一資源識別項 (URI) 。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

SetAccountPictureAsync(IStorageFile)

使用 IStorageFile 物件設定使用者帳戶的圖片。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

SetAccountPictureFromStreamAsync(IRandomAccessStream)

使用 IRandomAccessStream 物件設定使用者帳戶的圖片。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

SetAccountPicturesAsync(IStorageFile, IStorageFile, IStorageFile)

使用 IStorageFile 物件設定使用者帳戶的圖片。 支援新增小型影像、大型影像和視訊。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

SetAccountPicturesFromStreamsAsync(IRandomAccessStream, IRandomAccessStream, IRandomAccessStream)

使用 IRandomAccessStream 物件設定使用者帳戶的圖片。 支援新增小型影像、大型影像和視訊。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

事件

AccountPictureChanged

發生于使用者的映射或名稱變更時。

重要

Windows 10或更新版本不支援UserInformation類別。 請改用 User 類別。 請參閱 UserInformation 類別檔中的。

適用於

另請參閱