通知application2有关注册表项形式application1中的更改 [英] Notify application2 about the change in the registry key form application1

查看:43
本文介绍了通知application2有关注册表项形式application1中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有2个Windows应用程序,Application1&应用2.

Application1将向注册表项写入一个布尔值.一旦写入注册表项,Application1就需要将对注册表项所做的更改通知给Application2,以便Application2可以基于注册表项的值来完成其工作.

因此,Application1每次更改注册表项时都需要告知Application2.

我将如何实现呢?

我已经遍历了消息队列,WaitEventHandle,远程处理,WCF内容,但是我的体系结构不支持远程处理,WCF,消息队列.

所以我决定使用WaitEventHandle,但是Application2需要等到Application1响应,如果Application1不响应,Application2将等待无限时间.这真的很糟糕.

请给我建议其他解决方案,或使用其他事件类型.

预先感谢.

Hi,

I have 2 Windows Applications, Application1 & Application2.

Application1 will write a boolean value to the registry key. As soon as it writes to the registry key, Application1 need to notify Application2 about the changes done to the registry key so that Application2 can do its work based on the registry key value.

So, Application1 need to tell Application2 each time it makes changes to registrykey.

How will i achieve this?

I have already gone through Message Queues, WaitEventHandle, Remoting, WCF stuffs, but my architecture doesnot support Remoting, WCF, Message Queues.

So i decided to use WaitEventHandle, but Application2 need to wait until Application1 responds, What if Application1 doesnot respond, Application2 will wait for infinite time. This is really bad.

Please suggest me some other solutions, or using some other event types.

Thanks in advance.

推荐答案



如果注册表值已更改,则可以订阅事件.每当值由application1或其他任何人更改时,都会在application2中触发.请参见此处的示例:
在.NET中使用强类型WMI类进行异步注册表通知 [ ^ ]
Hi,

you could subscribe to an event if the registry value has changed. This would fire in application2 every time the value was changed by application1 or anyone else. See here for an example:
Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET[^]


关于您的方法,我有几点注意事项.

看起来您是在进行集成而不是进行开发.出于应用目的而使用多个过程的整个想法令人怀疑.

特别是,应尽量避免使用变量.假设您的用户卸载了您的软件.您是否要负责从注册表中删除数据.如果不是,请想象其他产品会做类似的事情(实际上,某些产品确实在做,这是不良产品的一个好兆头).您用户的注册表越来越多地受到污染……

您应该意识到,通过.NET,Microsoft促进了开发和支持风格,从而摆脱了使用Registry的局面.推荐的应用程序样式是,将应用程序简单地复制到磁盘上并立即开始工作,而删除后不会留下任何占用空间(特殊的应用程序数据目录除外).您需要适当的机制来进行应用程序的配置和设置(.NET中所有可用的和随时可用的)以及适当的IPC.

这是另一个问题.让我们看看你怎么写:

我已经遍历了消息队列,WaitEventHandle,远程处理,WCF的内容,但是我的体系结构不支持远程处理,WCF,消息队列."
您不认为有时您需要记住创建架构是为了满足应用程序的需求,而不是开发应用程序是为了开发架构?您选择的技术应该由您的应用程序目标定义,而不是相反.

无需询问明显可疑的技术,您可以共享项目的最终目标,想法,一些关键代码片段,并在问题"中进行讨论.您可能会在体系结构级别上获得更多有价值的建议.

只是要考虑的想法...

并且请原谅我讲课而不是回答您的问题(尽管您已经有了很好的答案).我只是认为您可以使用友善的建议来重新考虑您的一些方法.它真的可以帮助您.

—SA
I have a few of notes on your approach how I can see it.

It looks like you do integration instead of development. The whole idea of using more than one process the application purposes is a suspect.

In particular, variables should be avoided by all means. Imagine your user uninstalls your software. Do you want to take responsibility of removing your data from Registry. If not, imagine other products do something like this (indeed, some do, and this is a good sign of a bad product). Your user''s Registry gets contaminated more and more…

You should realize that with .NET Microsoft promotes development and support style to get away from using Registry. Most recommended style of application is that the application is simply copied to the disk and start working immediately without leaving any footprint when removed (exclusion is the special Application Data directories). You need appropriate mechanism for application configuration and setting (all available and ready-to-use in .NET) as well as appropriate IPC.

This is another problem. Let''s see what do you write:

"I have already gone through Message Queues, WaitEventHandle, Remoting, WCF stuffs, but my architecture doesnot support Remoting, WCF, Message Queues."
Don''t you think that sometimes you need to remember that you create your architecture in order to serve the needs of your applications, not that you develop applications in order to develop your architecture? The technologies you choose should be defined by your application goals, not the other way around.

Instead of asking about apparently questionable technique you could share the ultimate goals of your project, your ideas, some of your key code fragments and ask for discussion in your Question. Chances are, you could get more valuable advices on architectural level.

Just the idea to think about…

And please forgive me for delivering a lecture instead of answering your Question (you already have a good Answer though). I just thought you could use good friendly advice to re-think some of your approaches; it can really help you.

—SA


这篇关于通知application2有关注册表项形式application1中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆