G
Guest
Hi all,
my .NET program (Compact Framework) send to another my application
(unmanaged) a WM_COPYDATA message. My unmanaged application receive correctly
data from .NET application. Now my unmanaged application must be able to send
the same COPYDATASTRUCT struct thougth another WM_COPYDATA to my .NET
application. This .NET application receive message, but is not correct.
The code of my unmanaged app is:
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
switch(pCopyDataStruct->dwData)
{
case ID_REQUEST_DOWNLOAD_DWNSERVER:
if(m_hWndDWnServer != NULL)
{
::SendMessage(m_hWndDWnServer, WM_COPYDATA, (WPARAM)0,
(LPARAM)&pCopyDataStruct);
}
break;
default:
break;
}
return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
}
The code of my .NET app is:
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
{
case Win32.WM_COPYDATA:
unsafe
{
Win32.COPYDATASTRUCT st =
(Win32.COPYDATASTRUCT)Marshal.PtrToStructure(msg.LParam,
typeof(Win32.COPYDATASTRUCT));
string str = Marshal.PtrToStringUni(st.lpData, st.cbData);
}
break;
default:
base.WndProc(ref msg);
break;
}
}
str String does not contains the correct value. Why ?
my .NET program (Compact Framework) send to another my application
(unmanaged) a WM_COPYDATA message. My unmanaged application receive correctly
data from .NET application. Now my unmanaged application must be able to send
the same COPYDATASTRUCT struct thougth another WM_COPYDATA to my .NET
application. This .NET application receive message, but is not correct.
The code of my unmanaged app is:
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
switch(pCopyDataStruct->dwData)
{
case ID_REQUEST_DOWNLOAD_DWNSERVER:
if(m_hWndDWnServer != NULL)
{
::SendMessage(m_hWndDWnServer, WM_COPYDATA, (WPARAM)0,
(LPARAM)&pCopyDataStruct);
}
break;
default:
break;
}
return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
}
The code of my .NET app is:
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
{
case Win32.WM_COPYDATA:
unsafe
{
Win32.COPYDATASTRUCT st =
(Win32.COPYDATASTRUCT)Marshal.PtrToStructure(msg.LParam,
typeof(Win32.COPYDATASTRUCT));
string str = Marshal.PtrToStringUni(st.lpData, st.cbData);
}
break;
default:
base.WndProc(ref msg);
break;
}
}
str String does not contains the correct value. Why ?