1
0
mirror of synced 2024-12-30 00:03:09 +01:00
OpenTaiko/FDK19/コード/00.共通/CSendMessage.cs
2021-09-21 00:16:38 +02:00

34 lines
932 B
C#

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;
}
}
}