开发者

Change a variable contained in one process from a different process

开发者 https://www.devze.com 2023-01-21 14:47 出处:网络
(probably a dumb question) // Program_1.exe: int num = 1; using (Process process = new Process()) { process.StartInfo.FileName = \"Program_2.exe\";

(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(开发者_JS百科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?


You need to use some form of inter-process communication, such as WCF.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号