首页
社区
课程
招聘
[旧帖] [求助]学习BHO,写了一个插件,为什么不起作用 0.00雪花
发表于: 2011-12-5 11:21 1242

[旧帖] [求助]学习BHO,写了一个插件,为什么不起作用 0.00雪花

2011-12-5 11:21
1242
代码是参考网上的,获取Input的name 但是注册成功,点网页按钮的时候怎么不起作用
大牛帮我看看

  [ComVisible(true),
    Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
    ClassInterface(ClassInterfaceType.None)
    ]
    public class BHO:IObjectWiteSite
    {
        SHDocVw.WebBrowser webBrowser;
        HTMLDocument htmlDocument;
        
        public void OnDocumentComplete(object disp,ref object url)
        {
            try
            {
                htmlDocument = (HTMLDocument)webBrowser.Document;
                foreach (IHTMLInputElement tempElement in htmlDocument.getElementsByTagName("INPUT"))
                {
                    MessageBox.Show(tempElement.name!=null?tempElement.name:"it sucks,no name,try id"+((IHTMLElement)tempElement).id);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        public int SetSite([MarshalAs(UnmanagedType.IUnknown)] Object site)
        {
            if (site != null)
            {
                webBrowser = (SHDocVw.WebBrowser)site;
                webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            }
            else
            {
                webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
                webBrowser = null;
            }
            return 0;
        }
        public int GetSite(ref Guid guid, out IntPtr ppvSite)
        {
            IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
            int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
            Marshal.Release(punk);
            return 0;
        }

        public static string BHOKEYNAME = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";
        [ComRegisterFunction]
        public static void RegisterBHO(Type type)
        {
            RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME,true);
            if (registryKey == null)
                registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);

            string guid = type.GUID.ToString("B");
            RegistryKey outKey = registryKey.OpenSubKey(guid);
            if (outKey == null)
                outKey = registryKey.CreateSubKey(guid);
            outKey.SetValue("Alright", 1);
            registryKey.Close();
            outKey.Close();

        }
    }

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 1
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
抱歉 没有看明白啊
2011-12-5 12:55
0
游客
登录 | 注册 方可回帖
返回
//