CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: SendMessage

  1. #1
    Join Date
    Jun 2016
    Posts
    30

    SendMessage

    Hi,

    I'm trying to use the SendMessage for sending memory stream. I did some code, but not working. Here's my code

    Code:
                    stream.Seek(0, SeekOrigin.Begin);
                    
                    int dataSize = Convert.ToInt32(stream.Length);
                    byte[] byteArray = new byte[dataSize];
                    int count = stream.Read(byteArray, 0, 20);
                    
                    while(count < stream.Length)
                    {
                        byteArray[count++] = Convert.ToByte(stream.ReadByte());
                    }
    
                    IntPtr ptrData = Marshal.AllocCoTaskMem(dataSize);
                    Marshal.Copy(byteArray, 0, ptrData, dataSize);
    
                    CopyDataStruct cds = new CopyDataStruct
                    { 
                      cbData = dataSize,
                      dwData = (IntPtr)1,
                      lpData = ptrData
                    };
                       
                    SendMessage(hWnd, WM_COPYDATA, 0, cds);

    Thanks

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: SendMessage

    Seems to be quite a bit of info on the internet. Try searching for "SendMessage WM_COPYDATA in C#".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured