void _Receive(MessageItemData item, bool b) { //Console.WriteLine(item._num.ToString() + " 의 값이 들어왔습니다!"); this._view.result_int.Text = item._num.ToString(); this._view.result_double.Text = item._dnum.ToString(); this._view.result_double1.Text = item._todo[0].ToString(); this._view.result_double2.Text = item._todo[1].ToString(); this._view.result_double3.Text = item._todo[2].ToString(); this._view.result_string.Text = item.strTest.ToString(); this._view.result_boolean.Text = item.isRun.ToString(); }
// 텍스트 전송 함수 static bool _Send(MessageItemData messageitem) { bool bRet = false; int iSizeOfStruct = Marshal.SizeOf(typeof(MessageItemData)); IntPtr pmipout_itemdata = Marshal.AllocCoTaskMem(iSizeOfStruct); Marshal.StructureToPtr(messageitem, pmipout_itemdata, true); bRet = NativeMethods.Send(pmipout_itemdata); Console.WriteLine("\n---------- C# 에서 받은 구조체 ----------"); // 방법 1 : 변경된 구조체를 받는 방법 MessageItemData receivedata = (MessageItemData)Marshal.PtrToStructure(pmipout_itemdata, typeof(MessageItemData)); Marshal.FreeHGlobal(pmipout_itemdata); return(bRet); }