OSDN Git Service

Merge branch 'feature/37178_プロジェクトとソリューションファイルの英語化' into develop
[dtxmania/dtxmania.git] / FDK / コード / 00.共通 / CSendMessage.cs
diff --git a/FDK/コード/00.共通/CSendMessage.cs b/FDK/コード/00.共通/CSendMessage.cs
new file mode 100644 (file)
index 0000000..80d8410
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Text;
+
+namespace FDK
+{
+       public static class CSendMessage
+       {
+
+               [DllImport( "USER32.dll" )]
+               static extern uint SendMessage( IntPtr window, int msg, IntPtr wParam, ref SampleFramework.COPYDATASTRUCT lParam );
+       
+               
+               public static uint sendmessage( IntPtr MainWindowHandle, IntPtr FromWindowHandle, string arg)
+               {
+                       uint len = (uint) arg.Length;
+
+                       SampleFramework.COPYDATASTRUCT cds;
+                       cds.dwData = IntPtr.Zero;               // 使用しない
+                       cds.lpData = Marshal.StringToHGlobalUni( arg );                 // テキストのポインターをセット
+                       cds.cbData = ( len + 1 ) * 2;   // 長さをセット
+
+                       //文字列を送る
+                       uint result = SendMessage( MainWindowHandle, SampleFramework.WindowConstants.WM_COPYDATA, FromWindowHandle, ref cds );
+
+                       Marshal.FreeHGlobal( cds.lpData );
+
+                       return result;
+               }
+       }
+}