c# - 在 CustomActions 类中设置项目窗口处理程序

标签 c# windows-installer custom-action

我有一个 CustomInstaller 类 (System.Configuration.Install.Installer),基本上我在 Install 方法中打开一个对话框表单。 我想知道是否有可能以某种方式说该表单的“父”属性将是设置过程窗口?

我该怎么做?

最佳答案

您需要获取安装程序窗口的句柄。不太确定如何获得它,但 Process.GetCurrentProcess().MainWindowHandle 应该会给你很大的机会。然后创建一个 NativeWindow 来包装句柄,以便您可以将其用作所有者。像这样:

        IntPtr hdl = Process.GetCurrentProcess().MainWindowHandle;
        var window = new NativeWindow();
        window.AssignHandle(hdl);
        try {
            using (var dlg = new YourForm()) {
                var result = dlg.ShowDialog(window);
                //...
            }
        }
        finally {
            window.ReleaseHandle();
        }

关于c# - 在 CustomActions 类中设置项目窗口处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3246866/

相关文章:

c# - 在 XPath 中查找带有空格的类

带参数的c#设置项目

c# - .Net 中的自定义安装程序显示安装程序后面的表单

wix - 将命令行参数传递给 WiX 自定义操作

c++ - IntelliSense 引擎无法正常运行的错误太多

WiX 无法检查使用 CustomAction 设置的属性

c# - 是否可以在连接到 SQL Azure 数据库的 WCF 服务之间进行分布式事务?

c# - 从数组中删除精确的子数组值

c# - 在另一个类中使用一个类?

powershell - 通过 .cmd 文件安装 "azure-powershell.0.8.7.msi"时出现错误