What I want to get is the AppUserModelId of all installed StoreApp applications, so I can pass it to IApplicationActivationManager->ActivateApplication .
On Windows 8, it was saved in the registry, but on Windows 10 it no longer works.
There are a lot of questions about this on the Internet, but even after several days of searching, I could not find a satisfactory solution.
So far, I have been as follows:
- I am creating an instance of
IPackageManager , - I call
FindPackagesByUserSecurityId() with the SID of the current user, - I repeat the returned collection
- I get the
IPackage interface - From this, I get the
IPackageId interface, - Then I call
IPackageId->get_FamilyName()
With this, I have, for example, in Windows 10 for Windows Calculator the line " Microsoft.WindowsCalculator_8wekyb3d8bbwe ".
When I add " !App " to this line, I have the full AppUserModelId to start the Windows calculator: " Microsoft.WindowsCalculator_8wekyb3d8bbwe!App "
But not all applications use the " !App " named FamilyName. For example, Spartan uses the AppUserModelId " Microsoft.Windows.Spartan_cw5n1h2txyewy!Microsoft.Spartan.Spartan ", which does not end with " !App ". And when I replace " !Microsoft.Spartan.Spartan " with " !App ", it does not start → "This application does not support the specified contract."
So my question is: where can I get the last missing piece?
I found PowerShell code on the Internet ( http://poshcode.org/5702 ) that seems to do something very similar:
Get-AppXPackage $PackageName -pv Package | Get-AppxPackageManifest | % { foreach($Application in $_.Package.Applications.Application) { if($Application.Id -like $AppId) { if($Protocol -and !($Application.Extensions.Extension.Protocol.Name | ? { ($_ + "://") -match (($Protocol -replace '\*','.*') + "(://)?") })) { continue } [PSCustomObject]@{
I really don't understand this cryptic PowerShell stuff, but one line seems interesting to me:
foreach($Application in $_.Package.Applications.Application)
This seems to be an enumeration of applications in a package.
A comment in the same PowerShell code says:
so that $Application.Id missing.
If I could get the IAppInfo interface, I could call IAppInfo->get_Id() , and I would be ready.
But I do not know how to get this from IPackage in C ++.