110,534
社区成员
发帖
与我相关
我的任务
分享
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 lpValueBuf, ref int pcchValueBuf);
/// <summary>
/// 启动进程
/// </summary>
public static void Start(string Name,string FilePath)
{
try
{
Process[] myPS = System.Diagnostics.Process.GetProcessesByName(Name);
///如果没有启动,则启动
if (myPS.Length == 0)
{
Process mProcess = new Process();
mProcess.StartInfo.FileName = FilePath + "\\" + Name+".exe";
Directory.SetCurrentDirectory(FilePath);
mProcess.Start();
}
}
catch (Exception e)
{
}
}