* WM_COPYDATAを受ける [#h351d519]
#code(Csharp,nooutline){{
[StructLayout(LayoutKind.Sequential)]
private struct COPYDATASTRUCT {
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
private const int WM_COPYDATA = 0x4A;
protected override void WndProc(ref Message m) {
if(m.Msg==WM_COPYDATA){
COPYDATASTRUCT cds = new COPYDATASTRUCT();
cds = (COPYDATASTRUCT) Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
if (cds.cbData > 0) {
byte[] data = new byte[cds.cbData];
Marshal.Copy(cds.lpData, data, 0, cds.cbData);
//あとは data に COPYDATA の内容が入ってるので適宜処理
}
m.Result=(IntPtr)1;
}
base.WndProc (ref m);
}
}}