windows_programming_notes.nbk: Home | Index | Next Page: WM_CREATE | Previous Page: WM_COPY


 WM_COPYDATA

An application sends the WM_COPYDATA message to pass data to another application.

To send this message, call the SendMessage function with the following parameters (do not call the PostMessage function).

    SendMessage( 
      (HWND) hWnd,              // handle to destination window 
      WM_COPYDATA,              // message to send
      (WPARAM) wParam,          // handle to window (HWND)
      (LPARAM) lParam           // data (PCOPYDATASTRUCT)
    );

Parameters

Return Values

If the receiving application processes this message, it should return TRUE; otherwise, it should return FALSE.

Remarks

The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data.

While this message is being sent, the referenced data must not be changed by another thread of the sending process.

The receiving application should consider the data read-only. The lParam parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by lParam. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer.

When you send a WM_COPYDATA message, SendMessage allocates a block of memory cbData bytes in size and copies the data from the caller's address space to this block. It then sends the message to the destination window. When the receiving window procedure processes this message, the lParam parameter is a pointer to a COPYDATASTRUCT structure that exists in the address space of the receiving process. The lpData member is a pointer to the copied block of memory, and the address reflects the memory location in the receiving process's address space.

Requirements

  Windows NT/2000 or later: Requires Windows NT 3.1 or later.
  Windows 95/98/Me: Requires Windows 95 or later.
  Header: Declared in Winuser.h; include Windows.h.

windows_programming_notes.nbk: Home | Index | Next Page: WM_CREATE | Previous Page: WM_COPY


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time