从另一个进程更改一个进程中包含的变量
(可能是一个愚蠢的问题)
// Program_1.exe:
int num = 1;
using (Process process = new Process())
{
process.StartInfo.FileName = "Program_2.exe";
if (process.Start())
{
process.WaitForExit();
}
}
Console.WriteLine(num.ToString()); // num should now equal 2
伪代码
// Program_2.exe:
// I want this program to change the value of a variable in Program_1.exe
Program_1.exe->num = 2;
这可能吗?
如果可以,我该怎么做?
(probably a dumb question)
// Program_1.exe:
int num = 1;
using (Process process = new Process())
{
process.StartInfo.FileName = "Program_2.exe";
if (process.Start())
{
process.WaitForExit();
}
}
Console.WriteLine(num.ToString()); // num should now equal 2
Psuedocode
// Program_2.exe:
// I want this program to change the value of a variable in Program_1.exe
Program_1.exe->num = 2;
Is this possible?
If so, how can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用某种形式的进程间通信,例如 WCF。
You need to use some form of inter-process communication, such as WCF.