0

I need to pass a object of a class from one c# application to another (Same machine different folders).

Tried following....

public static void SendMessageWithData( IntPtr destHandle,  IntPtr srcHandle )
        {
            COPYDATASTRUCT cds = new COPYDATASTRUCT();
            cds.dwData = srcHandle;            
            IntPtr iPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(cds));
            Marshal.StructureToPtr(cds, iPtr, true);

            SendMessage(destHandle, WM_COPYDATA, IntPtr.Zero, iPtr);

            Marshal.FreeCoTaskMem(cds.lpData);
            Marshal.FreeCoTaskMem(iPtr);
        }
Dipto
  • 2,720
  • 2
  • 22
  • 42
Buddhi Dananjaya
  • 643
  • 2
  • 12
  • 32
  • 2
    What does 'not working' mean? What call does not work? Why are you ignoring the result returned from SendMessage? If it's the SendMessage call that's failing, why are you not calling GetLastError? Have you made any attempt to debug the problem at all? If so, what did you find out? – Martin James Jan 23 '14 at 07:39
  • It crashes at "SendMessage" – Buddhi Dananjaya Jan 23 '14 at 08:41
  • I think dwData should just be storing a number representing the type of message rather than the data. http://stackoverflow.com/questions/12743962/c-sharp-to-c-process-with-wm-copydata-passing-struct-with-strings – James_UK_DEV Jan 23 '14 at 16:47

0 Answers0