从托管代码获取安装日期

use*_*309 7 c# windows-installer wix

是否有托管API使用产品GUID检索应用程序的安装日期?

谢谢.斯科特

use*_*309 10

谢谢Rob!我在下面添加了一个完整的C#示例.

    [DllImport("msi.dll", CharSet = CharSet.Unicode)]
    static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);

    static void Main(string[] args)
    {
        Int32 len = 512;
        var builder = new StringBuilder(len);
        MsiGetProductInfo("{0db93d2f-a9e7-417f-9425-5e61e82c0868}", "InstallDate", builder, ref len);

        var installDate = DateTime.ParseExact(builder.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture);

        Console.WriteLine(installDate);
    }
Run Code Online (Sandbox Code Playgroud)


Rob*_*ing 8

获取该信息的"正确"方法是使用:: MsiGetProductInfo().PInvoke应该是微不足道的.