代码如下:
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 GetHWND
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//根据类名和窗体标题查找该窗体句柄
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern IntPtr FindWindowEx(
int hWnd1,
int hWnd2,
string lpsz1,
string lpsz2
); // 获得窗口矩形
[DllImport("user32")]
public static extern int GetWindowRect(int hwnd, ref RECT lpRect);
// 获得客户区矩形
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, ref RECT lpRect); // 矩形结构
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
int left;
int top;
int right;
int bottom;
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
IntPtr i = FindWindowEx(0, 0, "#32770", "多多游戏-对对碰V2.24");
RECT rc=new RECT();
if (i.ToInt32() != 0)
{
GetWindowRect(i, ref rc);
messagebox.show( rc.left)==================>此处,无法用rc.点出任何属性.而用断点查看,发现rc中的确有值
}
}
}
}
分数不富裕,还请理解.
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 GetHWND
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//根据类名和窗体标题查找该窗体句柄
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern IntPtr FindWindowEx(
int hWnd1,
int hWnd2,
string lpsz1,
string lpsz2
); // 获得窗口矩形
[DllImport("user32")]
public static extern int GetWindowRect(int hwnd, ref RECT lpRect);
// 获得客户区矩形
[DllImport("user32.dll")]
public static extern int GetClientRect(IntPtr hWnd, ref RECT lpRect); // 矩形结构
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
int left;
int top;
int right;
int bottom;
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
IntPtr i = FindWindowEx(0, 0, "#32770", "多多游戏-对对碰V2.24");
RECT rc=new RECT();
if (i.ToInt32() != 0)
{
GetWindowRect(i, ref rc);
messagebox.show( rc.left)==================>此处,无法用rc.点出任何属性.而用断点查看,发现rc中的确有值
}
}
}
}
分数不富裕,还请理解.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货