·上一篇:SQL 常用的语句以及使用方法详解
·下一篇:VB 两种方法建立多级目录
VB 编写自动注册IE的BHO插件程序
手工注册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中即可完成自动注册。

评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论