//FindWindow 查找窗口
//FindWindowEx查找子窗口
//EnumWindows列举屏幕上的所有顶层窗口,如果回调函数成功则返回非零,失败则返回零
//GetWindowText返回窗口的标题

一、首先要先导入要使用到的win api

[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern int EnumWindows(EnumWindowsProc hWnd, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpText, int nCount);
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam); private const int WM_GETTEXT = 0x00D;
private static string _url; //定义委托 delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); static void Main(string[] args)
{
string url = GetWindowText(); Console.WriteLine(url);
Console.ReadKey(); } public static string GetWindowText()
{ IntPtr chrom = IntPtr.Zero;
EnumWindowsProc enwdproc = new EnumWindowsProc(FindChrom); if (EnumWindows(enwdproc, IntPtr.Zero) >= )
return _url;
else
return null;
} //回调函数
static bool FindChrom(IntPtr hWnd, IntPtr lParam)
{ var sb = new StringBuilder();
GetWindowText(hWnd, sb, sb.Capacity); if (sb.ToString() != String.Empty)
{
if (hWnd != IntPtr.Zero)
{
IntPtr tb = FindWindowEx(hWnd, new IntPtr(), "Chrome_OmniboxView", ""); //Chrome_OmniboxView是通过Spy++获得的 StringBuilder strbld = new StringBuilder();
SendMessage(tb, WM_GETTEXT, , strbld);
_url = strbld.ToString();
}
return false; }
//回调函数有返回值 return true; }

C# 调用win api获取chrome浏览器中地址的更多相关文章

  1. 在Chrome浏览器中保存的密码有多安全?

    本文由 伯乐在线 - 黄利民 翻译.未经许可,禁止转载!英文出处:howtogeek.欢迎加入翻译组. [2013-08-09 更新]:最近又开始讨论“Chrome浏览器明文保存密码这个话题了,国外一 ...

  2. 【js】IE、FF、Chrome浏览器中的JS差异介绍

    如何判断浏览器类型 转:http://www.cnblogs.com/carekee/articles/1854674.html 1.通过浏览器特有的对象 如ie 的ActiveXObject  ff ...

  3. 渗透技巧——导出Chrome浏览器中保存的密码

    0x00 前言 在后渗透阶段,获得权限后需要搜集目标系统的信息.信息越全面,越有助于进一步的渗透.对于Windows系统,用户浏览器往往包含有价值的信息. 在之前的文章<本地密码查看工具LaZa ...

  4. 导出Chrome浏览器中保存的密码

    title: 导出Chrome浏览器中保存的密码 date: 2018-02-11 17:54:51 tags: --- 导出Chrome浏览器中保存的密码 先知看到的,挺有意思,记录一下 不同浏览器 ...

  5. Google Chrome浏览器中如何使用命令

    Google Chrome浏览器中如何使用命令 | 浏览:2974 | 更新:2014-02-23 23:12 | 标签:chrome 1 2 3 分步阅读 Google Chrome浏览器有很多的特 ...

  6. 调用ZoomEye API获取信息

    最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块urllib,json,os模块. 功能:调用ZoomEye API获取信息 import urllib.requ ...

  7. 去掉chrome浏览器中input获得焦点时的带颜色边框呢

    可以设置表单控件的outline属性为none值, 来去掉Chrome浏览器中输入框以及其它表单控件获得焦点时的带颜色边框. css代码如下: input{outline:none}

  8. [转]chrome浏览器中 F12 功能的简单介绍

    本文转自:https://www.cnblogs.com/zhuzhubaoya/p/9758648.html chrome浏览器中 F12 功能的简单介绍 由于F12是前端开发人员的利器,所以我自己 ...

  9. 查看 chrome 浏览器中的 Headers

    查看 chrome 浏览器中的 Headers, Response 信息:

随机推荐

  1. iOS 坐标系转换

    已知button的frame,如果要计算button相对于view的frame,则可以使用以下方法 CGRect rc = [btn.superview convertRect:btn.frame t ...

  2. 在drop user之前,建议获取该用户的依赖情况

    在删除这两个用户之前,建议获取这两个用户的依赖情况: SQL> col owner format a15 SQL> col name format a15 SQL> col REFE ...

  3. How to add total page to Odoo Report(7.0 version)

    add this codes to your rml file: <drawRightString x="19.5cm" y="0.3cm">Pag ...

  4. Qt之模式、非模式对话框

    关于“模式”和“非模式”对话框,相信大家都比较熟悉,但其中有一个可能很多人都比较陌生,介于两者之间的状态,我们称之为“半模式“. 模式对话框 描述 阻塞同一应用程序中其它可视窗口输入的对话框.模式对话 ...

  5. a5调试

    1 generating rsa key...[    4.452000] mmc0: error -110 whilst initialising SD card[    5.602000] mmc ...

  6. CRM认识的误区

    众所周知,CRM,就是平时说的“客户关系管理”,指用CRM来管理 企业与客户之间的关系.纵观整个IT圈子,做CRM的厂商比比皆是,每个厂商都有自己的产品宣言,令人眼花缭乱.但是领很多老板们不解的是,我 ...

  7. 换个角度剖析iptables防火墙

    这篇文章会尽量以通俗易懂的方式描述iptables的相关概念,请耐心的读完它. 防火墙相关概念 此处先描述一些相关概念. 从逻辑上讲.防火墙可以大体分为主机防火墙和网络防火墙. 主机防火墙:针对于单个 ...

  8. PAT005 Path in a Heap

    题目: Insert a sequence of given numbers into an initially empty min-heap H. Then for any given index ...

  9. C#实现反射调用动态加载的DLL文件中的方法

    反射的作用:1. 可以使用反射动态地创建类型的实例,将类型绑定到现有对象,或从现有对象中获取类型 2. 应用程序需要在运行时从某个特定的程序集中载入一个特定的类型,以便实现某个任务时可以用到反射.3. ...

  10. 设置grid高度

    $("#jqxSalaryCalculation").jqxGrid({ height: $("#jqxTree").height() - 73 });