用户登录  |  用户注册
首 页源码下载网络学院最新源码源码排行屏蔽广告
当前位置:新兴网络 > 网络学院 > 编程开发 > Visual Basic

VB 编写自动注册IE的BHO插件程序

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2010-12-22 12:01:06

手工注册BHO插件非常麻烦,要运行regsvr32命令来注册,还要插找注册表中对应的clisd值,而且要进HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\下新建一下以刚才那个dll的clisd为名称的项。
以下通过VB编写程序实现自动完成这些步骤:

VBScript code复制代码
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Sub main()
    On Error Resume Next
    Dim ta As Object, ti As Object, tc As Object
    Dim wsh As Object

    Set wsh = CreateObject("wscript.shell")
    Set ta = CreateObject("tli.TLIApplication")
    Set ti = CreateObject("tli.TLIApplication")
    Set tc = CreateObject("tli.TLIApplication")

    Dim cl As String, pid As Long, h As Long
    cl = Command
    pid = Shell("cmd /c regsvr32 /s " + cl, vbHide)
    h = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    WaitForSingleObject h, -1
    cl = Replace$(cl, """", "")
    Set ti = ta.TypeLibInfoFromFile(cl)
    Dim clisd As String
    For Each tc In ti.CoClasses
        clisd = tc.Guid
        wsh.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\" + clisd + "\", "MyBHO"
    Next
    End
End Sub

以上代码生成EXE后,把BHO的dll拖进exe中即可完成自动注册。

附件下载.rar

Tags:BHO VB 插件 浏览器

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      100%(2)
  • 差的评价 如果您觉得此文章差,就请您
      0%(0)

网络学院评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论