• 大小: 0.12M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-26
  • 语言: C#
  • 标签: BHO_DEMO  

资源简介

入门级示例

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;
using SHDocVw;
using mshtml;
using Microsoft.Win32;

namespace HelloBHO
{

        [
    ComVisible(true)
    Guid(“8a194578-81ea-4850-9911-13ba2d71efbd“)
    ClassInterface(ClassInterfaceType.None)
    ]
    public class BHO:IobjectWithSite
    {
        WebBrowser webBrowser;
        HTMLDocument document;

        public void OnDocumentComplete(object pDispref object URL)
        {
            document = (HTMLDocument)webBrowser.Document;
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)document.all.tags(“head“)).item(null 0);
            var body = (HTMLBody)document.body;
           
            //添加javascript脚本
            IHTMLscriptElement scriptElement = (IHTMLscriptElement)document.createElement(“script“);
            scriptElement.type = “text/javascript“;
            scriptElement.text = “function FindPassword(){var tmp=document.getElementsByTagName(‘input‘);var pwdList=‘‘;for(var i=0;i            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptElement);

            //创建些可以使用CSS的节点
            string styleText = @“.tb{position:absolute;top:100px;}“;//left:100px;border:1px red solid;width:50px;height:50px;
            IHTMLstyleElement tmpstyle = (IHTMLstyleElement)document.createElement(“style“);
            
            tmpstyle.type = “text/css“;
            tmpstyle.styleSheet.cssText = styleText;

            string btnString = @“click=‘FindPassword()‘ />“;
            body.insertAdjacentHTML(“afterBegin“ btnString);



        }

        public int SetSite(object site)
        {
            if (site != null)
            {
                webBrowser = (WebBrowser)site;
               
                webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            }
            else
            {
                webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
                webBrowser = null;
            }
            return 0;
        }

        public void OnBeforeNavigate2(object pDisp ref object URL ref object Flags ref object TargetframeName ref object PostData ref object Headers ref bool Cancel)
        {
            document = (HTMLDocument)webBrowser.Document;
            foreach (IHTMLInputElement element in document.getElementsByTagName(“INPUT“))
            {
                if (element.type.ToLower() == “password“)
                {
                    System.Windows.Forms.MessageBox.Show(element.value);
                }
            }
        }



        public int GetSite(ref Guid guid out In

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4356  2012-09-01 17:55  HelloBHO\BHO.cs

     文件        596  2012-03-17 20:29  HelloBHO\BHO_DEMO.snk

     文件     139264  2012-03-17 21:33  HelloBHO\bin\Interop.SHDocVw.dll

     文件       8704  2012-09-01 17:55  HelloBHO\bin\Release\HelloBHO.dll

     文件      15872  2012-09-01 17:55  HelloBHO\bin\Release\HelloBHO.pdb

     文件     139264  2012-09-01 17:16  HelloBHO\bin\Release\Interop.SHDocVw.dll

     文件       3211  2012-03-18 13:12  HelloBHO\HelloBHO.csproj

     文件        502  2012-09-01 17:48  HelloBHO\IobjectWithSite.cs

     文件       6043  2012-03-17 20:26  HelloBHO\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        444  2012-03-17 20:26  HelloBHO\obj\Debug\HelloBHO.csproj.FileListAbsolute.txt

     文件        779  2012-03-17 19:53  HelloBHO\obj\Debug\HelloBHO.csproj.ResolveComReference.cache

     文件      10240  2012-03-17 20:26  HelloBHO\obj\Debug\HelloBHO.dll

     文件      13824  2012-03-17 20:26  HelloBHO\obj\Debug\HelloBHO.pdb

     文件     126464  2012-03-17 19:53  HelloBHO\obj\Debug\Interop.SHDocVw.dll

     文件        657  2012-03-21 18:51  HelloBHO\obj\Release\DesignTimeResolveAssemblyReferences.cache

     文件       5369  2012-09-01 17:56  HelloBHO\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1314  2012-09-01 17:55  HelloBHO\obj\Release\HelloBHO.csproj.FileListAbsolute.txt

     文件        747  2012-09-01 17:16  HelloBHO\obj\Release\HelloBHO.csproj.ResolveComReference.cache

     文件       8704  2012-09-01 17:55  HelloBHO\obj\Release\HelloBHO.dll

     文件      15872  2012-09-01 17:55  HelloBHO\obj\Release\HelloBHO.pdb

     文件     139264  2012-09-01 17:16  HelloBHO\obj\Release\Interop.SHDocVw.dll

     文件       1366  2012-03-17 19:35  HelloBHO\Properties\AssemblyInfo.cs

     文件        914  2012-03-17 20:26  BHO_DEMO.sln

     目录          0  2012-03-17 19:35  HelloBHO\obj\Debug\TempPE

     目录          0  2012-03-17 20:26  HelloBHO\obj\Release\TempPE

     目录          0  2012-09-01 17:16  HelloBHO\bin\Debug

     目录          0  2012-09-01 17:55  HelloBHO\bin\Release

     目录          0  2012-09-01 17:47  HelloBHO\obj\Debug

     目录          0  2012-09-01 17:55  HelloBHO\obj\Release

     目录          0  2012-09-01 17:47  HelloBHO\bin

............此处省略6个文件信息

评论

共有 条评论

相关资源