Arbie
2009-08-24 22:31:48 UTC
Hi
I am rewriting a C++ application to C# and am a bit stuck on translating a
Copydata structure. This is used to copy a block of ushort data from another
application.
I have defined
public class Win32
{
[StructLayout(LayoutKind.Sequential)]
public class CopyDataStruct
{
public int dwData;
public int cbData;
public IntPtr data;
}
}
and am receiving the message ok with
unsafe protected override void WndProc(ref Message m)
{
if (m.Msg == WM_COPYDATA)
{
Win32.CopyDataStruct cds = new Win32.CopyDataStruct();
Marshal.PtrToStructure((IntPtr)m.LParam.ToPointer(), cds);
}
base.WndProc(ref m);
}
but how do I use the IntPtr cds.data to fill out a buffer of
matching size
something like
Array.Copy((System.Array)cds.data, adcBuffer, adcBufferSize);
thanks for any help
Rambler
I am rewriting a C++ application to C# and am a bit stuck on translating a
Copydata structure. This is used to copy a block of ushort data from another
application.
I have defined
public class Win32
{
[StructLayout(LayoutKind.Sequential)]
public class CopyDataStruct
{
public int dwData;
public int cbData;
public IntPtr data;
}
}
and am receiving the message ok with
unsafe protected override void WndProc(ref Message m)
{
if (m.Msg == WM_COPYDATA)
{
Win32.CopyDataStruct cds = new Win32.CopyDataStruct();
Marshal.PtrToStructure((IntPtr)m.LParam.ToPointer(), cds);
}
base.WndProc(ref m);
}
but how do I use the IntPtr cds.data to fill out a buffer of
matching size
something like
Array.Copy((System.Array)cds.data, adcBuffer, adcBufferSize);
thanks for any help
Rambler