Windows 使用环境变量在两个应用程序之间进行通信 问题:
如何通过环境变量(不是系统变量或用户变量)与另一个程序(例如,windows服务程序)通信 我们有什么 我有以下数据记录器方案:Windows 使用环境变量在两个应用程序之间进行通信 问题:,windows,windows-services,environment-variables,c++builder,Windows,Windows Services,Environment Variables,C++builder,如何通过环境变量(不是系统变量或用户变量)与另一个程序(例如,windows服务程序)通信 我们有什么 我有以下数据记录器方案: ------------------------- -------------------------------- | the things to measure | | the things that do something | ------------------------- --------------
------------------------- --------------------------------
| 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 |
--------
有办法吗?
我们不会使用系统和用户环境变量,因为它写在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 |
--------
-----------------------------------------------------------
|要衡量的事情| |做某事的事情|
------------------------- --------------------------------
| ^
|传感器|开关
五|
-------------------------------------------------------------------
|专用硬件|
-------------------------------------------------------------------
| ^
||串行通信
五|
--------------- -------------
| | ------------------------------------> | |
|| udp通信(端口3)||
||(从传感器获取数据)||
|Windows | |用户|
|服务| |接口|
||(端口1)||
| | ------------------------------------> | |
||无法与环境变量通信,进程只能更新其本地副本。使用Windows中可用的任何进程互操作机制,如套接字、命名管道或内存映射文件。使用UDP毫无意义,请使用TCP以便获得交付保证。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 |
--------