My suggestion is to look at using System.Runtime.InteropServices;
Here is some code that I wrote to send a message to another process on the
same box.
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam,
IntPtr lParam);
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern uint RegisterWindowMessage(string lpString);
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox1.Checked)
{
IntPtr handle = FindWindow(null, "xxx Monitor");
if(handle != IntPtr.Zero)
{
uint x_GenerateEvent = RegisterWindowMessage("ZM_GenerateEvent");
SendMessage(handle, x_GenerateEvent, UIntPtr.Zero, IntPtr.Zero);
int attempts = 0;
while (attempts < 5)
{
Thread.Sleep(1000); // allow the file to be created by other process
if (WorkOnFile() == true)
break;
attempts++;
}
if (attempts == 5)
{
MessageBox.Show("file not found by WorkOnFile()");
}
else
{
checkBox1.Checked = false;
}
}
else
{
MessageBox.Show("Cannot find xxx Monitor window");
}
}
}
Note: The "xxx Monitor" process written in C creates a file after I send a
message.
hope it helps --tony
"dthom" wrote:
Well to clarify, it is simple two applications (running as services) running
on the same PC.
Thats also why i find socketcommunciation to and from localhost abit
overkill - its not that its hard (the PC applications is in fact a
socketserver) - but i just hoped there was somekind of messaging system /
memory-mapped-file similiar kindof sharing data between processes.
The problem ofcourse, the one is CSharp, the other is C++ - and i dont have
the full overview over CSharp as i do with C++.