当前位置: 首页>>代码示例>>C#>>正文


C# Session.FormatRecord方法代码示例

本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Session.FormatRecord方法的典型用法代码示例。如果您正苦于以下问题:C# Session.FormatRecord方法的具体用法?C# Session.FormatRecord怎么用?C# Session.FormatRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Deployment.WindowsInstaller.Session的用法示例。


在下文中一共展示了Session.FormatRecord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRegistryPath

 private string GetRegistryPath(Session session, RegistryRoot root, string key, string name)
 {
     bool allUsers = session.EvaluateCondition("ALLUSERS = 1", true);
     string rootName = "????";
     switch(root)
     {
         case RegistryRoot.LocalMachine : rootName = "HKLM"; break;
         case RegistryRoot.CurrentUser  : rootName = "HKCU"; break;
         case RegistryRoot.Users        : rootName = "HKU"; break;
         case RegistryRoot.UserOrMachine: rootName = (allUsers ? "HKLM" : "HKCU"); break;
         case RegistryRoot.ClassesRoot  : rootName = (allUsers ? @"HKLM\Software\Classes" : @"HKCU\Software\Classes"); break;
         // TODO: Technically, RegistryRoot.ClassesRoot should be under HKLM on NT4.
     }
     if(name.Length == 0) name = "(Default)";
     if(name == "+" || name == "*") name = "";
     else name = " : " + name;
     using(Record formatRec = new Record(0))
     {
         formatRec[0] = String.Format(@"{0}\{1}{2}", rootName, key, name);
         return session.FormatRecord(formatRec);
     }
 }
开发者ID:zooba,项目名称:wix3,代码行数:22,代码来源:components.cs

示例2: GetComponentRegistryRows

        private object[][] GetComponentRegistryRows(string productCode, string componentCode, Session session, bool includeComponent)
        {
            ArrayList rows = new ArrayList();
            string componentPath = new ComponentInstallation(componentCode, productCode).Path;

            string componentKey = (string) session.Database.ExecuteScalar(
                "SELECT `Component` FROM `Component` WHERE `ComponentId` = '{0}'", componentCode);
            if(componentKey == null) return null;
            int attributes = Convert.ToInt32(session.Database.ExecuteScalar(
                "SELECT `Attributes` FROM `Component` WHERE `Component` = '{0}'", componentKey));
            bool registryKeyPath = (attributes & (int) ComponentAttributes.RegistryKeyPath) != 0;
            if(!registryKeyPath && componentPath.Length > 0) componentPath = Path.GetDirectoryName(componentPath);
            string keyPath = (string) session.Database.ExecuteScalar(
                "SELECT `KeyPath` FROM `Component` WHERE `Component` = '{0}'", componentKey);

            using (View view = session.Database.OpenView("SELECT `Registry`, `Root`, `Key`, `Name`, " +
                "`Value` FROM `Registry` WHERE `Component_` = '{0}'", componentKey))
            {
                view.Execute();

                foreach (Record rec in view) using (rec)
                {
                    string regName = (string) rec["Name"];
                    if(regName == "-") continue;  // Don't list deleted keys

                    string regTableKey = (string) rec["Registry"];
                    bool isKey = registryKeyPath && keyPath == regTableKey;
                    string regPath = this.GetRegistryPath(session, (RegistryRoot) Convert.ToInt32(rec["Root"]),
                        (string) rec["Key"], (string) rec["Name"]);

                    string dbValue;
                    using(Record formatRec = new Record(0))
                    {
                        formatRec[0] = rec["Value"];
                        dbValue = session.FormatRecord(formatRec);
                    }

                    string installedValue = this.GetRegistryValue(regPath);
                    bool exists = installedValue != null;
                    if(!exists) installedValue = "";
                    bool match = installedValue == dbValue;

                    object[] row;
                    if(includeComponent) row = new object[] { isKey, regTableKey, regPath, exists, dbValue, installedValue, match, componentCode };
                    else row = new object[] { isKey, regTableKey, regPath, exists, dbValue, installedValue, match };
                    rows.Add(row);
                }
            }

            return (object[][]) rows.ToArray(typeof(object[]));
        }
开发者ID:zooba,项目名称:wix3,代码行数:51,代码来源:components.cs


注:本文中的Microsoft.Deployment.WindowsInstaller.Session.FormatRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。