Reputation: 2626
From my legacy application (running under seperate process) I am sending double values in an object like this
#define MYMESSAGECODE (WM_APP + 123 )
typedef struct
{
float f;
double d;
} MyDataStruct;
MyDataStruct data;
data.f = 1.0;
data.d = 2.0;
pWpfWnd->SendMessage( MYMESSAGECODE, 0, (LPARAM) &data );
This is received in a WndProc in a seperate process Like this
private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case GA_SLOT_COORDINATES:
// Need solution here to convert lParam to MyDataStruct
}
return IntPtr.Zero;
}
I want to convert the data passed in lParam from my legacy application to same object in my .Net application running under different process. How can I achieve that? Thanks!!
Upvotes: 0
Views: 2289
Reputation: 73482
If you are intra process Marshal.PtrToStructure
will help you.
It seems you're trying to do this across the process, that's not possible. Your LParam
is a pointer to memory in another process, you can't share memory just like that. You need to use any of Inter process communication techniques. Take a look at Wm_CopyData.
Upvotes: 1