02、获取 win 8 程序包信息

 

 

命名空间:   Windows.ApplicationModel

1、获取应用程序安装文件夹的路径:

  // This will give the Installed Location.  You can use this location to access files, if you need them.
            Windows.Storage.StorageFolder installedLocation = Package.Current.InstalledLocation;
txt.Text = String.Format("Installed Location: {0}", installedLocation.Path);

 

 

2、获取包版本信息:

 String versionString(PackageVersion version)
        {
            return String.Format("{0}.{1}.{2}.{3}",
                                 version.Major, version.Minor, version.Build, version.Revision);
        }

3、获取应用程序所支持的处理器体系结构:

 String architectureString(Windows.System.ProcessorArchitecture architecture)
        {
            switch (architecture)
            {
                case Windows.System.ProcessorArchitecture.X86:
                    return "x86";
                case Windows.System.ProcessorArchitecture.Arm:
                    return "arm";
                case Windows.System.ProcessorArchitecture.X64:
                    return "x64";
                case Windows.System.ProcessorArchitecture.Neutral:
                    return "neutral";
                case Windows.System.ProcessorArchitecture.Unknown:
                    return "unknown";
                default:
                    return "???";
            }
        }

4、应用程序包信息:

// 调用 2、 3、 中的方法:

            Package package = Package.Current;
            PackageId packageId = package.Id;

            OutputTextBlock.Text = String.Format("Name: \"{0}\"\n" +
                                                 "Version: {1}\n" +
                                                 "Architecture: {2}\n" +
                                                 "ResourceId: \"{3}\"\n" +
                                                 "Publisher: \"{4}\"\n" +
                                                 "PublisherId: \"{5}\"\n" +
                                                 "FullName: \"{6}\"\n" +
                                                 "FamilyName: \"{7}\"\n" +
                                                 "IsFramework: {8}",
                                                 packageId.Name,
                                                 versionString(packageId.Version),
                                                 architectureString(packageId.Architecture),
                                                 packageId.ResourceId,
                                                 packageId.Publisher,
                                                 packageId.PublisherId,
                                                 packageId.FullName,
                                                 packageId.FamilyName,
                                                 package.IsFramework);

 

你可能感兴趣的:(in)