using System.Runtime.InteropServices;
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
[DllImport("User32.dll", EntryPoint = "SendMessage")] //用于发送信息给窗体
private static extern int SendMessage(IntPtr hWnd,
int Msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
[StructLayout(LayoutKind.Sequential)]
![](/Images/OutliningIndicators/None.gif)
public struct COPYDATASTRUCT
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
![](/Images/OutliningIndicators/InBlock.gif)
public IntPtr dwData;
![](/Images/OutliningIndicators/InBlock.gif)
public int cbData;
![](/Images/OutliningIndicators/InBlock.gif)
public IntPtr lpData;
![](/Images/OutliningIndicators/InBlock.gif)
}
COPYDATASTRUCT cds;
string a = "032";
byte[] sarr = System.Text.Encoding.Default.GetBytes(a);
![](/Images/OutliningIndicators/None.gif)
cds.dwData = (IntPtr)0;
cds.cbData = a.Length;
cds.lpData = Marshal.AllocHGlobal(sarr.Length);
Marshal.Copy(sarr, 0, cds.lpData, sarr.Length);
![](/Images/OutliningIndicators/None.gif)
IntPtr p = FindWindow("#32770", "GetMessage");
SendMessage(p, 0x004A, (IntPtr)0,ref cds);
posted @
2007-09-21 17:40
ahuo
阅读(
760)
评论()
编辑
收藏
举报