How to start a process with extra data and then search for this process?
<p>I have an <em>agent</em> program that will launch multiple instance of the same executable. Each of those instances need to have an individual ID associated with them.</p>

<p>The agent retains a reference to the <code>Process</code> object that was used to load the instance, but I have to consider that the agent may be shut down and restarted without affecting the started instances.</p>

<p>Once the agent starts again, I need it to search the existing processes and <em>rebind</em> a reference to the processes.</p>

<p>How can I assign data to a process and retrieve it afterwards?</p>

<p>Right now, I am starting the process like this:</p>

<pre><code>this.AttachedProcess = new Process()
{
    StartInfo = new ProcessStartInfo(filename)
};
</code></pre>

<p>And, later, I need to search for that process by calling <code>Process.GetProcesses()</code>.</p>

<p>While I could use a command line argument to start the process (something like <code>-instance XX</code>) and read that command line using <a href="http://stackoverflow.com/questions/504208/how-to-read-command-line-arguments-of-another-process-in-c/504378#504378">this answer</a>, I'd like to know if there is another way to assign extra data to a process and retrieve it later.</p>
