WM_COPYDATA inter-process communication scheme, wm_copydata Communication
WM_COPYDATA is used in two companies to implement inter-process communication.
Procedure:
1. process A starts process B through ShellExecute and passes the hWndA (strongly converted to int value) of the window handle used for communication to process B through the command line parameter, and B saves hWndA.
2. process B assembles the message COPYDATASTRUCT copyData, contains the window handle hWndB used for communication, and sends the WM_COPYDATA message to hWndA:
SendMessage (hWndA, WM_COPYDATA, 0, (LPARAM) & copyData );
When process A receives the WM_COPYDATA message, it also uses this mode to store hWndB. process A needs to send A message to process B:
SendMessage (hWndB, WM_COPYDATA, 0, (LPARAM) & copyData );
The process communication path is complete.
The dwData in COPYDATASTRUCT is used to store the message type.
Note: When WM_COPYDATA is received, Post a custom message number to yourself, immediately return the message, and perform other operations based on the custom message number.