【IT168 技术文档】C#可调用API接口来获取窗口句柄,代码如下:
using System;
using System.Runtime.InteropServices;
namespace tstfindwindow
{
///
/// Class1 的摘要说明。
///
class Class1
{
[DllImport( "User32.dll ")]
public static extern System. IntPtr FindWindowEx(System. IntPtr parent, System. IntPtr childe, string strclass, string strname);
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main(string[] args)
{
//
//TODO: 在此处添加代码以启动应用程序
//
IntPtr p=FindWindowEx(System.IntPtr.Zero,System.IntPtr.Zero,null,"窗口标题");
}
}
using System.Runtime.InteropServices;
namespace tstfindwindow
{
///
/// Class1 的摘要说明。
///
class Class1
{
[DllImport( "User32.dll ")]
public static extern System. IntPtr FindWindowEx(System. IntPtr parent, System. IntPtr childe, string strclass, string strname);
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main(string[] args)
{
//
//TODO: 在此处添加代码以启动应用程序
//
IntPtr p=FindWindowEx(System.IntPtr.Zero,System.IntPtr.Zero,null,"窗口标题");
}
}