[英]Communication between two applications using Environment Variables
如何通过环境变量(而不是系统或用户变量)与另一个程序(例如,Windows服务程序)通信?
好吧,对于数据记录器,我有以下方案:
------------------------- --------------------------------
| the things to measure | | the things that do something |
------------------------- --------------------------------
| ^
| sensors | switches
V |
-------------------------------------------------------------------
| dedicated hardware |
-------------------------------------------------------------------
| ^
| | serial communication
V |
--------------- -------------
| Windows | ------------------------------------> | user |
| service | <------------------------------------ | interface |
--------------- udp communication -------------
|^ keyboard
V| and screen
--------
| user |
--------
关于当前的发展:
GetData()
命令并对其进行响应) SetSensors()
命令并对其进行响应) 用户界面和Windows服务都在Borland C + Builder 6上开发,并使用FastNet选项卡中的NMUDP组件进行UDP通信。
由于某些缓冲区问题,并且为了释放udp通道而仅用于发送SetSensors()
命令并对其进行响应,我们正在考虑代替使用GetData()
:
------------------------- --------------------------------
| the things to measure | | the things that do something |
------------------------- --------------------------------
| ^
| sensors | switches
V |
-------------------------------------------------------------------
| dedicated hardware |
-------------------------------------------------------------------
| ^
| | serial communication
V |
--------------- -------------
| | ------------------------------------> | |
| | environment variables | |
| | (get data from sensors) | |
| Windows | | user |
| service | | interface |
| | | |
| | ------------------------------------> | |
| | <------------------------------------ | |
--------------- udp communication -------------
(send commands to service) |^ keyboard
V| and screen
--------
| user |
--------
我们不会使用系统和用户环境变量,因为它是在Windows注册表上编写的,即它将保存到硬盘驱动器并且变得越来越慢...
正如@HansPassant所说,我不能直接这样做。 尽管我看到了一些通过内存映射文件执行此操作的方法,但仅通过另一个端口添加一个udp通信通道非常容易。 所以:
------------------------- --------------------------------
| the things to measure | | the things that do something |
------------------------- --------------------------------
| ^
| sensors | switches
V |
-------------------------------------------------------------------
| dedicated hardware |
-------------------------------------------------------------------
| ^
| | serial communication
V |
--------------- -------------
| | ------------------------------------> | |
| | udp communication (port 3) | |
| | (get data from sensors) | |
| Windows | | user |
| service | | interface |
| | (port 1) | |
| | ------------------------------------> | |
| | <------------------------------------ | |
--------------- udp communication (port 2) -------------
(send commands to service) |^ keyboard
V| and screen
--------
| user |
--------
如果有人提供更好的解决方案,我会在以后将其标记为解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.