是否可以在 C# 中单击按钮而不是在设置自定义操作中调用安装程序类?
如果用户没有管理员权限。如何在按钮单击事件上调用安装程序类,该事件从注册表中读取数据并将值写入 C# 中的注册表?
因为当用户进行注册时我收到错误,它会在注册表中写入值,并且用户无权写入注册表。所以我知道只有安装程序类才有权利这样做。那么我怎样才能做到这一点呢?
If the user does not have admin permissions. How can I call the installer class on the button click event which reads from the registry and also write a value to the registry in c#?
Because I am getting an error when the user goes to registration it writes value in registry and the users do not have rights to write to registry. So i know that only the installer class has the right to do that. So how can I make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
推荐的方法是使用两种不同的自定义操作:
这样您就不会遇到权限问题。
The recommended approach is to use two different custom actions:
This way you shouldn't have permission problems.
没有一个可能有效的理由想要这样做。安装程序类自定义操作无法访问 MSI 句柄。这意味着他们无法获取/设置属性。唯一可用于更改计算机的配置,这违背了从用户界面序列中执行此操作的所有 Windows Installer 最佳实践。
UI 中按钮上唯一应该做的事情是验证处理,必须在进入下一个对话框之前完成。一个示例是验证用户输入,例如用于连接到 SQL 服务器的凭据。连接到 SQL Server 并使用它执行某些操作的繁重工作应该作为执行序列中的延迟自定义操作来完成。
我建议研究一下 WiX DTF。这公开了比安装程序类自定义操作更多的功能,并允许您创建遵循最佳实践的解决方案。
There isn't one possibly valid reason to want to do this. Installer class custom actions have no access to the MSI handle. This means they can't get/set properties. The only thing that can be used for is to change the configuration of the machine and it goes against all Windows Installer best practices to do this from within the User Interface Sequence.
The only thing that should be done on a button in the UI is validation processing that must be done before going to the next dialog. An example would be validating user input such as credentials for connecting to a SQL server. The heavy lifting of connecting to the SQL server and doing something with it should be done as deferred custom actions in the execute sequence.
I suggest looking into WiX DTF. This exposes more functionality then Installer class custom actions and allows you to create solutions that follow best practices.