取控件句柄
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.Diagnostics;
namespace WindowsFormsApplication16
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
p rivate void button1_Click(object sender, EventArgs e)
{
//IntPtr hwnd= Process.GetProcessById().MainWindowHandle;
String str1 = null;
str1 += "button1句柄:";
str1+=button1.Handle.ToString();
//str1 += "\r\n";
str1 += Environment.NewLine;
str1 += "checkbox1句柄:";
str1 += checkBox1.Handle.ToString();
//str1 += "\r\n";
str1 += Environment.NewLine;
str1 += "label1句柄:";
str1 += label1.Handle.ToString();
//str1 += "\r\n";
str1 += Environment.NewLine;
str1 += "radioButton1句柄:";
str1 += radioButton1.Handle.ToString();
//str1 += "\r\n";
str1 += Environment.NewLine;
textBox1.Text = str1;
}
}
}