• C# 获取msi文件的ProductCode


    private string GetProductCode()
    {
    System.Type oType
    = System.Type.GetTypeFromProgID("WindowsInstaller.Installer");
    Installer inst
    = System.Activator.CreateInstance(oType) as Installer;
    Database DB
    = inst.OpenDatabase("msi文件完整路径", MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
    string str = "SELECT * FROM Property WHERE Property = 'ProductCode'";

    WindowsInstaller.View thisView
    = DB.OpenView(str);
    thisView.Execute();
    WindowsInstaller.Record thisRecord
    = thisView.Fetch();
    string result = thisRecord.get_StringData(2);

    return result;
    }

    注意添加WindowsInstaller的引用:c:\windows\sytem32\msi.dll。

  • 相关阅读:
    什么是https?
    Gojs
    GoJs 01讲解
    你真的了解WebSocket吗?
    django channels
    序列化及反序列化
    全角转半角
    Thread Culture
    设置输入法
    token的认证使用
  • 原文地址:https://www.cnblogs.com/miaochw/p/2076442.html
Copyright © 2020-2023  润新知