简体   繁体   English

如何在正在运行的程序中更改变量?

[英]How to change variables in a running program?

For example I have a vector in my c++ program: 例如,我的c ++程序中有一个向量:

vector<string> files;

And this program is already running. 并且该程序已经在运行。

I want to invoke my other program to dynamically add a string to files vector (in already running program). 我想调用我的其他程序以在文件向量中动态添加一个字符串(在已经运行的程序中)。

Should I make a client-server application on localhost for that? 我应该为此在本地主机上创建客户端-服务器应用程序吗?
Or are there other methods? 还是有其他方法? (how to send message with params to the running program) (如何将带有参数的消息发送到正在运行的程序)

I can't give a great answer because I'm not experienced, but these are a few of the things I'm planning to look into: 我没有很好的答案,因为我没有经验,但这是我计划研究的一些内容:

Maybe something in there will be useful for you. 也许其中的某些内容对您有用。 Interprocess communication is the term you want to search for (IPC). 进程间通信是您要搜索的术语(IPC)。

There are quite a few ways to do this. 有很多方法可以做到这一点。 Google for Inter process communication. Google for Inter沟通。 http://en.wikipedia.org/wiki/Inter-process_communication http://en.wikipedia.org/wiki/进程间通信

On Windows I would use something like that: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366551(v=vs.85).aspx 在Windows上,我将使用类似的方法: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/aa366551(v=vs.85).aspx

Or just a temporary file if I you want to be quick and dirty about it. 或者,如果我想让它变得快速又肮脏,则只是一个临时文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM