const int WM_GETTEXT = 0x000D;
const int WM_GETTEXTLENGTH = 0x000E;
IntPtr hwndCalc = FindWindow(null, "硬盘序列号更改工具");
// 此句???? 用Edit类名,可以找到子控件的句柄,但是那个软件里面 有三个Edit的类名 用标题 1234-5678 就找不到句柄,咋个原因呢?
IntPtr hwndThree = FindWindowEx(hwndCalc, 0, "Edit", null);
SetForegroundWindow(hwndCalc);
if (hwndCalc != IntPtr.Zero)
{
int TextLen;
TextLen = SendMessage((int)hwndThree, WM_GETTEXTLENGTH, 0, 0);
Byte[] byt = new Byte[TextLen];
SendMessage((int)hwndThree, WM_GETTEXT, TextLen + 1, byt);
string str = Encoding.Default.GetString(byt);
}
const int WM_GETTEXTLENGTH = 0x000E;
IntPtr hwndCalc = FindWindow(null, "硬盘序列号更改工具");
// 此句???? 用Edit类名,可以找到子控件的句柄,但是那个软件里面 有三个Edit的类名 用标题 1234-5678 就找不到句柄,咋个原因呢?
IntPtr hwndThree = FindWindowEx(hwndCalc, 0, "Edit", null);
SetForegroundWindow(hwndCalc);
if (hwndCalc != IntPtr.Zero)
{
int TextLen;
TextLen = SendMessage((int)hwndThree, WM_GETTEXTLENGTH, 0, 0);
Byte[] byt = new Byte[TextLen];
SendMessage((int)hwndThree, WM_GETTEXT, TextLen + 1, byt);
string str = Encoding.Default.GetString(byt);
}
解决方案 »
- c# win ce 键盘钩子
- 如何计算某种字体的半角空格及字符串的宽度?(.net2005 winform)急~~~~~
- 关于this.Hide()的困惑——程序由登录窗口进入MDI窗口时如何写代码?
- C#怎样实现对ACCESS数据库中的数据进行查询
- Windows 2000 Pro比Windows XP Pro运行Visual Studio.NET 2003速度哪个快?(笔记本上)
- c# 如何删除datagridview中数据并删除数据库中的数据
- 窗体程序之间的交互
- [讨论] 弱引用有什么好处?
- 请教水晶报表中ReportDocument的打印问题,不通过CrystalReportViewer如何让用户选择打印机?
- 请问如果在两个窗体之间传递参数。
- 关于在WPF中文本框内容动态变化的问题
- 数组内部分组,分成5组,是每组之和尽量相等,求算法
[DllImport("user32", EntryPoint = "GetWindow")]
public static extern IntPtr GetWindow(
IntPtr hwnd,
int wFlag
);IntPtr hwndCalc = FindWindow(null, "硬盘序列号更改工具");
IntPtr hwndThree = FindWindowEx(hwndCalc, 0, "Edit", null);
hwndThree = GetWindow(hwndThree, 2);