How to get current AppInfo in UWP environment

后端 未结 2 1151

How can I get the current AppInfo of the running UWP application? I could not find any accessible constructor or static function to get this information.

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-27 20:47

    You could get App​Diagnostic​Info of all uwp apps that are running by the following code.

    var list = await App​Diagnostic​Info.RequestInfoAsync();
    

    And then you could get AppInfo from each item in the App​Diagnostic​Info list.

    foreach (var diagnosticinfo in list)
    {
        info = diagnosticinfo.AppInfo;
    }
    var id = info.Id;
    

    Please note that you need to declare the following capabilities in the Package.appxmainfest.

    
      
        
      
    
    

提交回复
热议问题