嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 20 元微信扫码支付:20 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
句柄操作大全
//查询主窗体
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string IpClassName, string IpWindowName);
//查找窗体控件
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
//应用程序发送此消息来设置一个窗口的文本
[DllImport("user32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
//应用程序发送此消息来接受一个窗口的文本
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam);
//应用程序发送此消息来接受一个窗口的文本
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.Text = "1000";
timer1.Interval = int.Parse(comboBox1.Text);
GetWindow();
}
/// <summary>
/// 获取窗体所有句柄存到list集合里便于使用
/// </summary>
private void GetWindow()
{
IntPtr IntPtrhWnd = FindWindow(null, "句柄测试小窗口");//获取主窗口句柄
if (IntPtrhWnd != null)
{
List<IntPtr> sub = GetIntPtr(IntPtrhWnd);//声明一个句柄集合 将主窗口句柄加载进去
#region 窗体放个listbox就取消注释
//int nub = 0;
//listBox1.Items.Clear();//清空控件
#endregion
jubing.Clear();//清空控件
wenben.Clear();//清空控件
foreach (IntPtr i in sub)//遍历句柄集合
{
//输出标题
StringBuilder strTemp = new StringBuilder(256);//声明一个数组
SendMessage(i, 0x000D, 256, strTemp);//获取i句柄与strTemp文本内容
jubing.Add(i);//句柄添加到集合里
wenben.Add(strTemp.ToString());
#region 窗体放个listbox就取消注释
//listBox1.Items.Add(nub.ToString() ": " i.ToString() "/" strTemp.ToString());
//nub ;
#endregion
}
}
.
├── 好例子网_句柄操作大全.zip
└── 句柄操作大全
├── Debug
│ ├── 句柄测试小窗口.exe
│ └── 句柄测试小窗口.pdb
├── 句柄操作大全
│ ├── Form1.Designer.cs
│ ├── Form1.cs
│ ├── Form1.resx
│ ├── LOGO.ico
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── bin
│ │ └── Debug
│ │ ├── 句柄操作大全.exe
│ │ └── 句柄操作大全.pdb
│ ├── obj
│ │ └── Debug
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── TempPE
│ │ ├── 句柄操作大全.Form1.resources
│ │ ├── 句柄操作大全.Properties.Resources.resources
│ │ ├── 句柄操作大全.csproj.CoreCompileInputs.cache
│ │ ├── 句柄操作大全.csproj.FileListAbsolute.txt
│ │ ├── 句柄操作大全.csproj.GenerateResource.cache
│ │ ├── 句柄操作大全.csprojAssemblyReference.cache
│ │ ├── 句柄操作大全.exe
│ │ └── 句柄操作大全.pdb
│ └── 句柄操作大全.csproj
├── 句柄操作大全.sln
└── 句柄测试小窗口.zip
9 directories, 27 files