Use CreateProcess And send WM_COPYDATA message
Posted on 2004-11-05
I have a process A to which i need to send WM_COPYDATA messages thru windows SendMessageTimeout api.
I first check whether the process is already running. If not, it first starts the process A.
I am using CreateProcess windows api to create the process. after the process is created i send a WM_COPYDATA message to the process. To get the handle of the process once it is created i tried following methods:
1) Get the handle from the ProxessInformation structure (pi) passed to the CreateProcess method as it contains the proxess handle once the process is created.
pOtherWnd = (HWND)pi.hProcess;
2) Get the handle of the process by using windows FindWindow api.
The problem is that the first time after the process is created, the OnCopyData() method in the process A is not getting called. From next time on (i.e. when the process A is found to be running already and no CreateProcess is called) the OnCopyData() method is called successfully.