本文整理汇总了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);
}
}
示例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[]));
}