如何通过环境变量(不是系统或用户)与其他程序(例如,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通信。
由于某些缓冲区问题并且只为发送SetSensors()
命令和响应而释放udp频道,我们正在考虑不使用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注册表上写入,即它将保存到硬盘驱动器并且它变得更慢......
答案 0 :(得分:0)
正如@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 |
--------
如果有人提供更好的解决方案,我会在将来将其标记为解决方案。