c# FindWindow 的用法,c#重写api,FindWindow
2014-01-07 11:15
513 查看
FindWindow这个函数检索处理顶级窗口的类名和窗口名称匹配指定的字符串。
函数原型:
HWND FindWindow
(
LPCSTR lpClassName,
LPCSTR lpWindowName
);
IpClassName :指向一个指定了类名的空结束字符串,或一个标识类名字符串的成员的指针。如果该参数为一个成员,则它必须为前次调用theGlobafAddAtom函数产生的全局成员。该成员为16位,必须位于IpClassName的低 16位,高位必须为 0。
IpWindowName:指向一个指定了窗口名(窗口标题)的空结束字符串。如果该参数为空,则为所有窗口全匹配。
C# 中的用法
using System.Runtime.InteropServices;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindow(string strClass, string strWindow);
使用:
IntPtr __handle;
__handle = FindWindow("Notepad", null);
if (__handle!=IntPtr.Zero){
}
__handle = FindWindow(null, "无标题 - 记事本");
if (__handle != IntPtr.Zero)
{
}
返回结果:
如果函数成功,返回值为具有指定类名和窗口名的窗口句柄;
如果函数失败,返回值为0。
函数原型:
HWND FindWindow
(
LPCSTR lpClassName,
LPCSTR lpWindowName
);
IpClassName :指向一个指定了类名的空结束字符串,或一个标识类名字符串的成员的指针。如果该参数为一个成员,则它必须为前次调用theGlobafAddAtom函数产生的全局成员。该成员为16位,必须位于IpClassName的低 16位,高位必须为 0。
IpWindowName:指向一个指定了窗口名(窗口标题)的空结束字符串。如果该参数为空,则为所有窗口全匹配。
C# 中的用法
using System.Runtime.InteropServices;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindow(string strClass, string strWindow);
使用:
IntPtr __handle;
__handle = FindWindow("Notepad", null);
if (__handle!=IntPtr.Zero){
}
__handle = FindWindow(null, "无标题 - 记事本");
if (__handle != IntPtr.Zero)
{
}
返回结果:
如果函数成功,返回值为具有指定类名和窗口名的窗口句柄;
如果函数失败,返回值为0。
相关文章推荐
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序[转]
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序[转]
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序[转]
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序
- C#用 SendKyes 结合 Process 或 API FindWindow、SendMessage(PostMessage) 等控制外部程序[转]
- c# api Showwindow/FindWindow/PostMessage
- c#里FindWindow的用法
- C# DllImport的用法 调用Window的一些常用功能
- c#调用api(FindFirstFile,FindNextFile)高效遍历目录文件【转载】
- C# 进程的MainWindowTitle为空的原因?C# 调用FindWindow找不到窗体的原因?
- c#里FindWindow的用法
- Delphi 中 FindWindow 和 FindWindowEx 的语法和用法
- SQLServer\framework启动报异常:Module的类型初始值设定项引发异常 [转]QQ空间、新浪微博、腾讯微博等一键分享API链接代码 window下 mongodb快速安装 数据表查询所有子/父节点 C#学习笔记1
- C# List<T>中Find的用法
- C# 查找窗口,FindWindow用法
- 在C#的类或结构中重写ToString方法的用法简介
- C#.NET使用Window API 制作淡入淡出特殊效果
- C# DllImport的用法 调用Window的一些常用功能