日期:2014-05-20 浏览次数:21683 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Accessibility;
namespace webgame
{
public partial class mian : Form
{
public mian()
{
InitializeComponent();
}
//①dll导入
//FindWindow
[DllImport("user32.dll")]
public static extern int FindWindow(string className, string title);
//FindWindowEx
[DllImport("user32.dll")]
public static extern int FindWindowEx(int parent, int next, string ClassName, string title);
//SetWindowText
[DllImport("user32")]
public static extern int SetWindowText(int handle, string title);
//GetWindowText
[DllImport("user32.dll")]
private static extern int GetWindowText(int hWnd, StringBuilder title, int size);
//GetClassName
[DllImport("user32.dll")]
private static extern int GetClassName(int hWnd, StringBuilder lpClassName, int nMaxCount);
//SendMessage
[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
//EnumWindows 需回调
[DllImport("user32.dll")]
//public static extern int EnumWindows(EnumWindowsProc lpfn, int lParam);
public static extern int EnumWindows(CallBack lpfn, int lParam);
//EnumChildWindows 需回调
[DllImport("user32.dll")]
public static extern int EnumChildWindows(int Parenthandle, CallBack lpfn, int lParam);
//获取窗口标题
[DllImport("user32", SetLastError = true)]
public static extern int GetWindowText(
IntPtr hWnd, //窗口句柄
StringBuilder lpString, //标题
int nMaxCount //最大值
);
//根据坐标获取窗口句柄
[DllImport("user32")]
private static extern IntPtr WindowFromPoint(
Point Point //坐标
);
//获取pid根据handle
[DllImport("user32", EntryPoint = "GetWindowThreadProcessId")]
private static extern int GetWindowThreadProcessId(int hwnd, out int pid);
//根据handle获取对象
[DllImport("atl.dll")]
private static extern int AtlAxGetControl(int hwnd,ref Object obj);
//获取对象