| 发表于:2007-02-19 23:00:51 楼主 |
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查找一个窗体的类名,返回窗体的句柄。 |
|
|
|
|