Note that there are some explanatory texts on larger screens.

plurals
  1. POGet localized friendly names for all winrt/metro apps installed from WPF application
    primarykey
    data
    text
    <p>My WPF application needs to list the localized names of all Metro/WinRT applications installed for the user. I created a repo to store a working sample for the code presented: <a href="https://github.com/luisrigoni/metro-apps-list" rel="nofollow noreferrer">https://github.com/luisrigoni/metro-apps-list</a></p> <p><strong>1)</strong> Using <code>PackageManager.FindPackagesForUser()</code> method</p> <pre><code>var userSecurityId = WindowsIdentity.GetCurrent().User.Value; var packages = packageManager.FindPackagesForUser(userSecurityId); foreach (var package in packages) Debug.WriteLine(package.Id.Name); } // output: // Microsoft.BingFinance // Microsoft.BingMaps // Microsoft.BingSports // Microsoft.BingTravel // Microsoft.BingWeather // Microsoft.Bing // Microsoft.Camera // microsoft.microsoftskydrive // microsoft.windowscommunicationsapps // microsoft.windowsphotos // Microsoft.XboxLIVEGames // Microsoft.ZuneMusic // Microsoft.ZuneVideo </code></pre> <p>These outputs don't seems too friendly to show to the user...</p> <p><strong>2)</strong> Reading the <code>AppxManifest.xml</code> of each of these apps</p> <pre><code>var userSecurityId = WindowsIdentity.GetCurrent().User.Value; var packages = packageManager.FindPackagesForUser(userSecurityId); foreach (var package in packages) { var dir = package.InstalledLocation.Path; var file = Path.Combine(dir, "AppxManifest.xml"); var obj = SerializationExtensions.DeSerializeObject&lt;Package&gt;(file); if (obj.Applications != null) { foreach (var application in obj.Applications) { Debug.WriteLine(application.VisualElements.DisplayName); } } } // output: // ms-resource:AppTitle // ms-resource:AppDisplayName // ms-resource:BingSports // ms-resource:AppTitle // ms-resource:AppTitle // ms-resource:app_name // ms-resource:manifestDisplayName // ms-resource:ShortProductName // ms-resource:mailAppTitle // ms-resource:chatAppTitle // ms-resource:///resources/residTitle // ms-resource:///strings/peopleAppName // ms-resource:///photo/residAppName // ms-resource:34150 // ms-resource:33273 // ms-resource:33270 </code></pre> <p>Definitely not friendly...</p> <p><strong>Update 1)</strong> Increasing above item (<strong>2</strong>) with <a href="http://www.pinvoke.net/default.aspx/shlwapi.shloadindirectstring" rel="nofollow noreferrer"><code>SHLoadIndirectString</code></a> funcion (hint by <a href="https://stackoverflow.com/a/18368775/1261906">Erik F</a>)</p> <pre><code>[DllImport("shlwapi.dll", BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false, ThrowOnUnmappableChar = true)] private static extern int SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, int cchOutBuf, IntPtr ppvReserved); static internal string ExtractStringFromPRIFile(string pathToPRI, string resourceKey) { string sWin8ManifestString = string.Format("@{{{0}? {1}}}", pathToPRI, resourceKey); var outBuff = new StringBuilder(1024); int result = SHLoadIndirectString(sWin8ManifestString, outBuff, outBuff.Capacity, IntPtr.Zero); return outBuff.ToString(); } [...] foreach (var application in obj.Applications) { Uri uri = new Uri(application.VisualElements.DisplayName); var resourceKey = string.Format("ms-resource://{0}/resources/{1}", package.Id.Name, uri.Segments.Last()); Debug.WriteLine(ExtractStringFromPRIFile("&lt;path/to/pri&gt;", resourceKey)); } [...] // output: // Finance // Maps // Sports // Travel // Weather // Bing // Camera // SkyDrive // Mail // Messaging // Calendar // People // Photos // Games // Music // Video </code></pre> <p>Much, much better. We already have english labels. But how to extract other language resources?</p> <p>I'm expecting retrieve the same label that is shown on Start Screen for each app, something like "Finanças", "Esportes", "Clima" if my language is pt-BR; "Finances", "Sports", "Weather" if my language is en-US.</p> <p><strong>[Q]</strong> Is there another way to get the application names? Maybe native/Win32 (DISM API/...)? Is possible to load the .pri file of each app to get the localized name?</p> <p>As said, an updated working sample is here: <a href="https://github.com/luisrigoni/metro-apps-list" rel="nofollow noreferrer">https://github.com/luisrigoni/metro-apps-list</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload