using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("User32.dll")]
        public static extern int FindWindow(string s);        public Form1()
        {
            InitializeComponent();
        }         private void button1_Click(object sender, EventArgs e)
        {
            int a;
            a=FindWindow("类名");
      textBox1.Text = a; //这样写说 无法将类型“int”隐式转换为“string”
            textBox1.Text = Convert.ToString(a);//这样写能运行,但一点按钮就出一窗口说“无法处理的异常”,不明白
        }
    }
}创建的是‘Windows应用程序’,功能很简单,就是用FindWindow查找一个窗体的类名,返回窗体的句柄。