[英]Communication between two applications using Environment Variables
How to communicate with another program (for instance, a windows service one) through environment variables (not system or user ones)? 如何通过环境变量(而不是系统或用户变量)与另一个程序(例如,Windows服务程序)通信?
Well, I have the following scheme for a data logger: 好吧,对于数据记录器,我有以下方案:
------------------------- --------------------------------
| 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 |
--------
On current development: 关于当前的发展:
GetData()
command and response to it) GetData()
命令并对其进行响应) SetSensors()
command and response to it) SetSensors()
命令并对其进行响应) Both user interface and windows service are developed on Borland C+ Builder 6 and use NMUDP component, from FastNet tab, for UDP communication. 用户界面和Windows服务都在Borland C + Builder 6上开发,并使用FastNet选项卡中的NMUDP组件进行UDP通信。
Because of some buffer issues and to free udp channel only for sending SetSensors()
command and response to it, we are considering that instead of using GetData()
: 由于某些缓冲区问题,并且为了释放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 |
--------
We would not use system and user environment variables, because it writes on Windows Registry, ie, it will save to hard drive and it gets more slow... 我们不会使用系统和用户环境变量,因为它是在Windows注册表上编写的,即它将保存到硬盘驱动器并且变得越来越慢...
As @HansPassant said, I cannot do that directly. 正如@HansPassant所说,我不能直接这样做。 Although I saw some ways to do that via memory mapped file, it is so easy only to add one more udp communication channel through other port.
尽管我看到了一些通过内存映射文件执行此操作的方法,但仅通过另一个端口添加一个udp通信通道非常容易。 So:
所以:
------------------------- --------------------------------
| 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 |
--------
If someone provide a better solution, I'll mark it as solution in future. 如果有人提供更好的解决方案,我会在以后将其标记为解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.