Here is the piece of code, which run through all the process and when It finds the right process, code sends the message. My question is what happened to the ‘proc’, how to dispose that process.
//get all other (possible) running instances
Process[] processes = Process.GetProcesses();
foreach (Process proc in processes)
{
if (proc.ProcessName.ToLower() == ProcessName.ToLower())
{
SendMessage(proc.MainWindowHandle, (uint)Message, IntPtr.Zero, IntPtr.Zero);
}
}
Thanks in advance,
Harsha
In general terms you don’t need to worry about disposing or deallocating objects, unless the object implements the
IDisposableinterface. If it does you should either call theDispose()method on it manually when you’re finished, or wrap with ausingstatement to have it called automatically: