LParameter tnSrcHWND, tnDstHWND, tcData, tnIdentifier *Declare API functions * Declare Long HeapAlloc in win32api Long, Long, Long Declare Long GetProcessHeap in win32api Declare Long HeapFree in win32api Long, Long, Long #define WM_COPYDATA 0x4A * Create a COPYDATASTRUCT structure * Local lcStruct, lnMem lnMem = HeapAlloc( GetProcessHeap(), 0, Len(m.tcData)+12 ) lcStruct = ; toInt(m.tnIdentifier,4) + ; toInt(Len(m.tcData),4) + ; toInt(m.lnMem+12,4) + ; m.tcData Sys(2600,m.lnMem,Len(m.lcStruct),m.lcStruct) *Send data to the other application * Local lnRetVal Declare Long SendMessage in win32api Long, Long, Long, Long lnRetVal = SendMessage( m.tnDstHWND, WM_COPYDATA, m.tnSrcHWND, lnMem ) * Free up memory * HeapFree( GetProcessHeap(), 0, m.lnMem ) Return m.lnRetValThat code shows how to send a mesage to another application (.Net in my case).
>protected override void WndProc(ref System.Windows.Forms.Message m) >{ > switch (m.Msg) > { > case WM_COPYDATA: > // do something > break; > } >base.WndProc(ref m); >} >>This method is automatically called when the VFP application sends data. You don't need an infinite loop if you call Application.Run(form).