mar*_*rry 2 windows-8 winjs windows-8.1
一些代码用于获取Windows 8商店应用程序上登录用户的用户名:
var x = Windows.System.UserProfile.UserInformation;
var y = x.getPrincipalNameAsync().done(function(response) {
console.log(response);
});
Run Code Online (Sandbox Code Playgroud)
我有两个虚拟机,Windows 8和Windows 8.1.该代码适用于Windows 8 VM上的解决方案,今天我按照本指南将我的应用程序重新定位到Windows 8.1.虽然重新定位工作,我可以将升级的.appx部署到8.1平板电脑,但上面的代码只返回"".
请帮忙.
从文档:
只有域用户具有主体名称.隐私设置可以阻止对主体名称的访问(例如,如果UserInformation :: NameAccessAllowed属性为false).如果访问被阻止,则此方法返回空字符串.
因此,您的用户可能不是域用户,或者您的Windows8计算机上的隐私与其他用户不同.
要确保您的隐私设置允许读取主体名称,请在设置中检查您的设备 - >更改电脑设置 - >隐私并打开所需的隐私设置.
这是完整的文档:http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.userinformation.getprincipalnameasync.aspx
| 归档时间: |
|
| 查看次数: |
269 次 |
| 最近记录: |