This is the example to show how to send a cstring from one application to another.
Paste this follwing code at sender.
CString csData(_T(""));
csData=" This is the message";
COPYDATASTRUCT copyDT;//Is used for Interprocess communication
copyDT.dwData = NULL;
copyDT.cbData = _tcslen(csData) + 1;
copyDT.lpData = ( void* ) ( ( LPCTSTR ) csData );
HWND hWnd = ::FindWindow(NULL,"Receiver application");
// Finding the handle of receiver application and send
// WM_COPYDATA message is used for Interprocess communication
if(hWnd!=NULL)
{
::SendMessage( hWnd, WM_COPYDATA, 0, (LPARAM)©DT );
}
At receiver add WM_COPYDATA message.
Paste the following code
CString csReceived;
csReceived=(LPCTSTR)pCopyDataStruct->lpData;
2 comments:
Thank u very much for this code.
Nitin Diwan
Thank u very much for this code
Nitin Diwan
Post a Comment