Beispiel #1
0
        public string GetStringValue(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            return(NativeApiHelper.GetStringValue(_app, name));
        }
Beispiel #2
0
        private static ManifestInfo GetAppInfoFromManifest(string manifestFilePath)
        {
            if (File.Exists(manifestFilePath))
            {
                var factory = (NativeApiHelper.IAppxFactory) new NativeApiHelper.AppxFactory();

                IStream manifestStream;

                NativeApiHelper.SHCreateStreamOnFileEx(manifestFilePath, STGM_SHARE_DENY_NONE, 0, false, IntPtr.Zero, out manifestStream);

                if (manifestStream != null)
                {
                    var manifestInfo = new ManifestInfo();

                    var reader     = factory.CreateManifestReader(manifestStream);
                    var properties = reader.GetProperties();

                    manifestInfo.Properties = properties;

                    var apps = reader.GetApplications();

                    while (apps.GetHasCurrent())
                    {
                        var app = apps.GetCurrent();
                        var manifestApplication = new ManifestApplication(app);

                        manifestApplication.AppListEntry      = NativeApiHelper.GetStringValue(app, "AppListEntry");
                        manifestApplication.Description       = NativeApiHelper.GetStringValue(app, "Description");
                        manifestApplication.DisplayName       = NativeApiHelper.GetStringValue(app, "DisplayName");
                        manifestApplication.EntryPoint        = NativeApiHelper.GetStringValue(app, "EntryPoint");
                        manifestApplication.Executable        = NativeApiHelper.GetStringValue(app, "Executable");
                        manifestApplication.Id                = NativeApiHelper.GetStringValue(app, "Id");
                        manifestApplication.Logo              = NativeApiHelper.GetStringValue(app, "Logo");
                        manifestApplication.SmallLogo         = NativeApiHelper.GetStringValue(app, "SmallLogo");
                        manifestApplication.StartPage         = NativeApiHelper.GetStringValue(app, "StartPage");
                        manifestApplication.Square150x150Logo = NativeApiHelper.GetStringValue(app, "Square150x150Logo");
                        manifestApplication.Square30x30Logo   = NativeApiHelper.GetStringValue(app, "Square30x30Logo");
                        manifestApplication.BackgroundColor   = NativeApiHelper.GetStringValue(app, "BackgroundColor");
                        manifestApplication.ForegroundText    = NativeApiHelper.GetStringValue(app, "ForegroundText");
                        manifestApplication.WideLogo          = NativeApiHelper.GetStringValue(app, "WideLogo");
                        manifestApplication.Wide310x310Logo   = NativeApiHelper.GetStringValue(app, "Wide310x310Logo");
                        manifestApplication.ShortName         = NativeApiHelper.GetStringValue(app, "ShortName");
                        manifestApplication.Square310x310Logo = NativeApiHelper.GetStringValue(app, "Square310x310Logo");
                        manifestApplication.Square70x70Logo   = NativeApiHelper.GetStringValue(app, "Square70x70Logo");
                        manifestApplication.MinWidth          = NativeApiHelper.GetStringValue(app, "MinWidth");
                        manifestInfo.Apps.Add(manifestApplication);
                        apps.MoveNext();
                    }
                    Marshal.ReleaseComObject(manifestStream);

                    return(manifestInfo);
                }
                else
                {
                    Debug.WriteLine("Call to SHCreateStreamOnFileEx failed on : " + manifestFilePath);
                }
            }
            else
            {
                Debug.WriteLine("Manifest File Missing: " + manifestFilePath);
            }

            return(null);
        }