By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,536 Members | 2,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,536 IT Pros & Developers. It's quick & easy.

what kind of ipc technologies for C# windows form applications.

P: n/a


I know you can use socket to talk to other application . But i have an old
;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other one
written with C#.
Well "web services" are out of question because i do not know if my old MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance
Nov 16 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
wm_copydata?
do you mean some kind of shared memory stuff?

otherwise I have a library which I plan to have shareware, but it's not yet
well documented, not yet on a web site where you could buy, but already
working with Pipes and Shared Memory implementation in C#.
(+ some remoting stuff you don't, unfortunatele, care)
(the problem is I'm slowly learning ASP.NET 2.0 so it will be ... delayed)

eventually if you're interested you could contact me: ld remove at skip
galador dot net

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old
;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other
one
written with C#.
Well "web services" are out of question because i do not know if my old
MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance

Nov 16 '05 #2

P: n/a
Hi,

You will have to intercept that message, overwriting WndProc of the form
receiving it. after that you can copy the data using marshalling, I dont
have an example here with me but I assure you that if you look in google you
will find plenty.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old
;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other one written with C#.
Well "web services" are out of question because i do not know if my old MFC centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance

Nov 16 '05 #3

P: n/a
Bredal,

If that is the case, then you could very easily define the SendMessage
API function and call that, passing the WM_COPYDATA message (and appropriate
paramters). You just have to make sure you have the windows handle of the
app, and you are set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old
;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other
one
written with C#.
Well "web services" are out of question because i do not know if my old
MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance

Nov 16 '05 #4

P: n/a
If i understands, this sounds like
p/Invoke, right?
well i would look for examples then. It may turn out to be very usefull .
Thank you
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> skrev i
en meddelelse news:OK**************@TK2MSFTNGP11.phx.gbl...
Bredal,

If that is the case, then you could very easily define the SendMessage
API function and call that, passing the WM_COPYDATA message (and appropriate paramters). You just have to make sure you have the windows handle of the
app, and you are set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old ;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other
one
written with C#.
Well "web services" are out of question because i do not know if my old
MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance


Nov 16 '05 #5

P: n/a
I do not know much about marshalling although i have heared much about it.
So i guess it is time to read something about it.

Howabout sending message from C# to MFC?

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> skrev
i en meddelelse news:uH**************@TK2MSFTNGP14.phx.gbl...
Hi,

You will have to intercept that message, overwriting WndProc of the form
receiving it. after that you can copy the data using marshalling, I dont
have an example here with me but I assure you that if you look in google you will find plenty.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old ;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other

one
written with C#.
Well "web services" are out of question because i do not know if my old

MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance


Nov 16 '05 #6

P: n/a
I'm not quiet sure what you library does but i'm not looking for shared
memory
neither Pipe stuff. My old app uses wm_copydata and there is too much code
written
with it to move to an other IPC mechanism.

But thanks anyway.

"Lloyd Dupont" <ld@NewsAccount.galador.net> skrev i en meddelelse
news:ux**************@TK2MSFTNGP15.phx.gbl...
wm_copydata?
do you mean some kind of shared memory stuff?

otherwise I have a library which I plan to have shareware, but it's not yet well documented, not yet on a web site where you could buy, but already
working with Pipes and Shared Memory implementation in C#.
(+ some remoting stuff you don't, unfortunatele, care)
(the problem is I'm slowly learning ASP.NET 2.0 so it will be ... delayed)

eventually if you're interested you could contact me: ld remove at skip
galador dot net

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old ;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an other
one
written with C#.
Well "web services" are out of question because i do not know if my old
MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance


Nov 16 '05 #7

P: n/a
Bredal,

Yes, you will use the P/Invoke layer. Basically, you will want to do
this:

[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
[MarshalAs(UnmanagedType.U4)]
public int dwData;
[MarshalAs(UnmanagedType.U4)]
public int cbData;
public IntPtr lpData;
}

And then you could define something very specific for SendMessage, since
it will only pass WM_COPYDATA:

[DllImport("user32.dll")]
private static extern IntPtr SendMessage(
IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)]
int Msg,
IntPtr wParam,
ref COPYDATASTRUCT lParam);

And then define a wrapper method, like this:

public static IntPtr SendCopyDataMessage(IntPtr toHandle, IntPtr fromHandle,
IntPtr data, int length)
{
// Create the structure.
COPYDATASTRUCT dataStruct = new COPYDATASTRUCT();

// Set the fields.
dataStruct.lpData = data;
dataStruct.cbData = length;

// Assume WM_COPYDATA is defined. Make the call.
return SendMessage(toHandle, WM_COPYDATA, fromHandle, ref dataStruct);
}

Of course, you can perform variants on this (passing in a byte array,
etc, etc).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If i understands, this sounds like
p/Invoke, right?
well i would look for examples then. It may turn out to be very usefull .
Thank you
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> skrev i
en meddelelse news:OK**************@TK2MSFTNGP11.phx.gbl...
Bredal,

If that is the case, then you could very easily define the
SendMessage
API function and call that, passing the WM_COPYDATA message (and

appropriate
paramters). You just have to make sure you have the windows handle of
the
app, and you are set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
>
>
> I know you can use socket to talk to other application . But i have an old > ;) MFC app that only
> speaks "wm_copydata". I want this appliccation to interact with an
> other
> one
> written with C#.
> Well "web services" are out of question because i do not know if my old
> MFC
> centrique app need
> to be bothered with web service.
>
> So what are the other alternatives.
>
>
> Many thanks in advance
>
>



Nov 16 '05 #8

P: n/a
Hi,

It's the same thing

You have to use marshalling to copy/read unmanaged memory and probably call
some API functions using P/Invoke

Again, search in google for working code.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:eD***************@tk2msftngp13.phx.gbl...
I do not know much about marshalling although i have heared much about it.
So i guess it is time to read something about it.

Howabout sending message from C# to MFC?

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> skrev i en meddelelse news:uH**************@TK2MSFTNGP14.phx.gbl...
Hi,

You will have to intercept that message, overwriting WndProc of the form
receiving it. after that you can copy the data using marshalling, I dont
have an example here with me but I assure you that if you look in google

you
will find plenty.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...


I know you can use socket to talk to other application . But i have an old ;) MFC app that only
speaks "wm_copydata". I want this appliccation to interact with an
other one
written with C#.
Well "web services" are out of question because i do not know if my
old MFC
centrique app need
to be bothered with web service.

So what are the other alternatives.
Many thanks in advance



Nov 16 '05 #9

P: n/a
Great thanks!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> skrev i
en meddelelse news:en**************@TK2MSFTNGP12.phx.gbl...
Bredal,

Yes, you will use the P/Invoke layer. Basically, you will want to do
this:

[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
[MarshalAs(UnmanagedType.U4)]
public int dwData;
[MarshalAs(UnmanagedType.U4)]
public int cbData;
public IntPtr lpData;
}

And then you could define something very specific for SendMessage, since it will only pass WM_COPYDATA:

[DllImport("user32.dll")]
private static extern IntPtr SendMessage(
IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)]
int Msg,
IntPtr wParam,
ref COPYDATASTRUCT lParam);

And then define a wrapper method, like this:

public static IntPtr SendCopyDataMessage(IntPtr toHandle, IntPtr fromHandle, IntPtr data, int length)
{
// Create the structure.
COPYDATASTRUCT dataStruct = new COPYDATASTRUCT();

// Set the fields.
dataStruct.lpData = data;
dataStruct.cbData = length;

// Assume WM_COPYDATA is defined. Make the call.
return SendMessage(toHandle, WM_COPYDATA, fromHandle, ref dataStruct);
}

Of course, you can perform variants on this (passing in a byte array,
etc, etc).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If i understands, this sounds like
p/Invoke, right?
well i would look for examples then. It may turn out to be very usefull .. Thank you
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> skrev i en meddelelse news:OK**************@TK2MSFTNGP11.phx.gbl...
Bredal,

If that is the case, then you could very easily define the
SendMessage
API function and call that, passing the WM_COPYDATA message (and

appropriate
paramters). You just have to make sure you have the windows handle of
the
app, and you are set.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bredal Jensen" <br****@jensen.dk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
>
>
> I know you can use socket to talk to other application . But i have an
old
> ;) MFC app that only
> speaks "wm_copydata". I want this appliccation to interact with an
> other
> one
> written with C#.
> Well "web services" are out of question because i do not know if my

old > MFC
> centrique app need
> to be bothered with web service.
>
> So what are the other alternatives.
>
>
> Many thanks in advance
>
>



Nov 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.