日期:2014-05-17 浏览次数:21147 次
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( "SOFTWARE ");
String [] names = rk.GetSubKeyNames();
foreach (String s in names)
{
//输出吧....
}
static void Main()
{
StringBuilder result = new StringBuilder();
for (int index = 0; ; index++)
{
StringBuilder productCode = new StringBuilder(39);
if (MsiEnumProducts(index, productCode) != 0)
{
break;
}
foreach (string property in new string[] { "ProductName", "Publisher", "VersionString", })
{
int charCount = 512;
StringBuilder value = new StringBuilder(charCount);
if (MsiGetProductInfo(productCode.ToString(), property, value, ref charCount) == 0)
{
value.Length = charCount;
result.AppendLine(value.ToString());
}
}
result.AppendLine();
}
Console.WriteLine(result.ToString());
}
[DllImport("msi.dll", SetLastError = true)]
static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
[DllImport("msi.dll", SetLastError = true)]
static extern int MsiGetProductInfo(string szProduct, string szProperty, StringBuilder lpV