FindWindow返回值永远是0,希望大神帮忙解决

爱撸铁的程序员 2017-03-03 03:56:51

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindow(string strClass, string strWindow);

IntPtr hh = FindWindow("Notepad", "");
MessageBox.Show(hh.ToString());


VS 2015 专业版 Win10
...全文
945 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2017-03-09
  • 打赏
  • 举报
回复
前面是窗口的类名,后面用标题名,你需要打开记事本,才能找到 参考如下 IntPtr hwnd = FindWindow(null, "计算器"); if (hwnd != IntPtr.Zero) { MessageBox.Show("找到计算器窗口"); } else { MessageBox.Show("没有找到计算器窗口"); } hwnd = FindWindow("Notepad", null); if (hwnd != IntPtr.Zero) { MessageBox.Show("找到记事本窗口"); } else { MessageBox.Show("没有找到记事本窗口"); } 另外,你的代码是.net的,这个pb版

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧