成功关闭另一个进程中的对话框
我有一个问题。问题是我有另一个进程调用了 ShowDialog() 方法,我需要从另一个进程关闭此对话框,但我需要通过返回 DialogResult.OK 来关闭它。
因此,从我的 .net 程序(另一个进程)中,我想成功关闭它。我尝试使用winapi来解决这个问题,尝试了EndDialog函数,但它返回ACCESS_DENIED错误。尝试使用钩子,但它们返回 error_no_token。
我需要它以静默方式启动 msi 安装程序。我用 /qn 开关启动它,但是这个该死的安装程序嵌入了在任何情况下都会显示对话框的操作。我尝试使用 sendmessage 函数关闭此窗口,但在这种情况下,安装程序说这是错误的,并回滚安装过程。我可以通过编程方式填充所有值,然后单击对话框上的“确定”按钮,但它需要填充所有值,而且值很多,因此非常耗时。此对话框的目的是创建配置文件,我可以在安装后手动创建该文件。
有什么办法可以完成这个任务吗?
I have a question. The problem is that I have another process which invoked ShowDialog() method, I need to close this dialog from another process but I need to close it with returning DialogResult.OK.
So from my .net program(another process) I want to close it successfully. I tried to use winapi to solve this problem, tried EndDialog function, but it returns error that ACCESS_DENIED. Tried to use hooks but those return error_no_token.
I need this to start msi installer silently. I start it with /qn switch, but this damn installer has embedded action that shows dialog in any case. I tried to close this window with sendmessage function, but in this case installer says that it is error, and rolls back the install process. I can fill all the values programmatically and click OK button on the dialog, but it requires to fill ALL THE VALUES, and there are lots of them, so it is time consuming. The purpose of this dialog is to create config file, which I can create manually later, after installation.
Is there any way to accomplish this task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您遇到的主要问题是围绕文本字段的验证进行最终运行。正如您所说,您稍后将编辑配置文件,只需在每个框中放置一些虚拟值,然后单击“确定”即可进行验证。
It sounds like the main issue you are having is doing a end-run around the validation for the text fields. As you said you would be editing the configuration files later just put some dummy values in each box and click the OK the way that causes the validation to happen.
有时,您需要更改糟糕的设计,以消除执行艰巨任务的需要,而不是继续与系统对抗。
UI 归一个进程所有,除了自动化测试之外,只能由该进程或用户更改。
Sometimes you need to change a bad design to remove the need to do a hard task, rather then keep fighting the system.
A UI is owned by one process, and apart from automating tests, should only be changed by that process or the user.
过去有一些针对系统管理员的安装程序工具包,它们会在运行安装程序时监视注册表和文件系统,然后创建自定义 MSI 文件来自动化该过程。这可能是你的另一种选择。
There used to be installer toolkits aims at system admins, that would watch the registry and file system while running a installer and then create a custom MSI file to automate the process. This may be another way for you to go.