Plugin.bas
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:11k
源码类别:
浏览器
开发平台:
Visual Basic
- Attribute VB_Name = "mPlugin"
- Option Explicit
- ''插件数据--脚本插件
- 'Public Type PluginData_Script
- ' 'Title As String
- ' Language As String
- ' Script As String
- ' LoadedScript As Boolean '是否加载了脚本
- ' 'FileName As String
- ' '程序启动时是否加载脚本,0:启动时不加载,1:启动时加载
- ' LoadAtExec As Long
- ' '执行类型,可以有三个值,0:在顶层页面中执行,1:在页面中的每一个frame都执行,2:仅在鼠标所在的frame中执行
- ' RunType As Long
- 'End Type
- '
- ''插件数据--exe插件
- 'Public Type PluginData_Exe
- ' 'Title As String
- ' 'FileName As String
- ' Param As String
- 'End Type
- '
- ''插件数据--com插件
- 'Public Type PluginData_Com
- ' 'Title As String
- ' 'FileName As String
- ' ObjectName As String
- ' ClassID As String
- 'End Type
- '
- ''插件数据--dll插件
- 'Public Type PluginData_Dll
- ' 'Title As String
- ' 'FileName As String
- ' message As Long
- ' Reserve As Long
- 'End Type
- 'Public Enum enumPluginModuleType
- ' PluginMT_None=
- ' PluginMT_Script = 1
- ' PluginMT_Exe = 2
- ' PluginMT_Com = 3
- ' PluginMT_Dll = 4
- 'End Enum
- ''插件数据
- 'Public Type PluginData
- ' Title As String '名称,对应于菜单或按钮显示的文字
- ' DirectExe As Long '是否直接的exe文件
- ' ModuleType As String 'script,exe,com,dll
- ' FileName As String '要执行的文件名,exe | ini
- ' Param As String
- '
- ' o_FileName As String 'ini中指向的真实文件名
- ' o_Title As String 'ini文件中的Title
- '
- ' Data_Script As PluginData_Script
- ' Data_Exe As PluginData_Exe
- ' Data_Com As PluginData_Com
- ' Data_Dll As PluginData_Dll
- 'End Type
- Public Const PluginTypeTag_Command$ = "command"
- Public Const PluginTypeTag_SideBand$ = "sideband"
- Public Const PluginTypeTag_ToolBand$ = "toolband"
- '插件(ini)文件标记
- Public Const LEPluginFlag$ = "LE_Plugin"
- Public gPlugins() As cPluginData ' PluginData '1 base
- Public gPluginCnt As Long
- 'sideband data
- Public gPluginsSideBand() As cPluginSideband '1 base
- Public gPluginSBCnt As Long
- 'Public gScripts() As ScriptData '1 base
- 'Public gScriptCnt As Long
- 'Public Const ScriptInfoFlag_Info = "Info"
- 'Public Const ScriptInfoFlag_Title = "Title"
- 'Public Const ScriptInfoFlag_Language = "Language"
- 'Public Const ScriptInfoFlag_Script = "[Script]"
- 'Public Const ScriptInfoFlag_RunType = "RunType"
- 'Public Const ScriptInfoFlag_LoadAtExec = "LoadAtExec"
- 'Private Function GetExtendName(vFile$) As String
- 'Dim tPos&
- '
- 'On Error Resume Next
- 'tPos = InStrRev(vFile, ".")
- 'If tPos > 0 Then
- ' GetExtendName = Mid(vFile, tPos + 1)
- 'Else
- ' GetExtendName = ""
- 'End If
- 'End Function
- Public Sub SavePlugin()
- Dim tIni As cINIFile
- Dim i&, tIS$
- Set tIni = New cINIFile
- With tIni
- .IniFile = AppPath & MainIniName
- .DeleteSection "Plugin"
- .WriteKey "Plugin", "Count", Str$(gPluginCnt)
- For i = 1 To gPluginCnt
- tIS = LTrim$(Str$(i))
- .WriteKey "Plugin", "Title_" & tIS, gPlugins(i).Title
- .WriteKey "Plugin", "FileName_" & tIS, gPlugins(i).FileName
- .WriteKey "Plugin", "Param_" & tIS, gPlugins(i).Param
- .WriteKey "Plugin", "VisInMenu_" & tIS, gPlugins(i).VisInMenu
- Next i
- .DeleteSection "Plugin_SideBand"
- .WriteKey "Plugin_SideBand", "Count", Str$(gPluginSBCnt)
- For i = 1 To gPluginSBCnt
- tIS = LTrim$(Str$(i))
- .WriteKey "Plugin_SideBand", "Title_" & tIS, gPluginsSideBand(i).Title
- .WriteKey "Plugin_SideBand", "FileName_" & tIS, gPluginsSideBand(i).FileName
- .WriteKey "Plugin_SideBand", "Param_" & tIS, gPluginsSideBand(i).Param
- .WriteKey "Plugin_SideBand", "VisInMenu_" & tIS, gPluginsSideBand(i).VisInMenu
- Next i
- End With
- End Sub
- Public Sub LoadPlugin()
- Call LoadPluginData(AppPath & MainIniName)
- Call LoadPluginData_SideBand(AppPath & MainIniName)
- End Sub
- '---------------------------------------------------------------------------------------
- ' Procedure : LoadPluginData
- ' DateTime : 2005-5-29 20:55
- ' Author : Lingll
- ' Purpose : 读取command型插件信息
- '---------------------------------------------------------------------------------------
- Public Sub LoadPluginData(vIniF$)
- Dim tIni As cINIFile
- Dim i&, tIS$
- Set tIni = New cINIFile
- tIni.IniFile = vIniF
- gPluginCnt = tIni.ReadInt("Plugin", "Count")
- If gPluginCnt > 0 Then
- ReDim gPlugins(0 To gPluginCnt)
- For i = 1 To gPluginCnt
- Set gPlugins(i) = New cPluginData
- tIS = LTrim$(Str$(i))
- gPlugins(i).Title = tIni.ReadKey("Plugin", "Title_" & tIS)
- gPlugins(i).FileName = tIni.ReadKey("Plugin", "FileName_" & tIS)
- gPlugins(i).Param = tIni.ReadKey("Plugin", "Param_" & tIS)
- gPlugins(i).VisInMenu = tIni.ReadInt("Plugin", "VisInMenu_" & tIS, 1)
- Next i
- Else
- gPluginCnt = 0
- ReDim gPlugins(0 To 0)
- End If
- Call ReloadPluginData
- 'Call LoadPluginsMenu
- End Sub
- '---------------------------------------------------------------------------------------
- ' Procedure : LoadPluginData_SideBand
- ' DateTime : 2005-5-29 20:56
- ' Author : Lingll
- ' Purpose : 读取sideband型插件信息
- '---------------------------------------------------------------------------------------
- Public Sub LoadPluginData_SideBand(vIniF$)
- Dim tIni As cINIFile
- Dim i&, tIS$
- Set tIni = New cINIFile
- tIni.IniFile = vIniF
- gPluginSBCnt = tIni.ReadInt("Plugin_SideBand", "Count")
- If gPluginSBCnt > 0 Then
- ReDim gPluginsSideBand(0 To gPluginSBCnt)
- For i = 1 To gPluginSBCnt
- Set gPluginsSideBand(i) = New cPluginSideband
- tIS = LTrim$(Str$(i))
- gPluginsSideBand(i).Title = tIni.ReadKey("Plugin_SideBand", "Title_" & tIS)
- gPluginsSideBand(i).FileName = tIni.ReadKey("Plugin_SideBand", "FileName_" & tIS)
- gPluginsSideBand(i).Param = tIni.ReadKey("Plugin_SideBand", "Param_" & tIS)
- gPluginsSideBand(i).VisInMenu = tIni.ReadInt("Plugin_SideBand", "VisInMenu_" & tIS, 1)
- Next i
- Else
- gPluginSBCnt = 0
- ReDim gPluginsSideBand(0 To 0)
- End If
- Call ReloadPluginData_SideBand
- End Sub
- Public Sub ReloadPluginData()
- Dim i&
- For i = 1 To gPluginCnt
- With gPlugins(i)
- gPlugins(i).Reload
- End With
- Next i
- End Sub
- Public Sub ReloadPluginData_SideBand()
- Dim i&
- For i = 1 To gPluginSBCnt
- With gPluginsSideBand(i)
- gPluginsSideBand(i).Reload
- End With
- Next i
- End Sub
- '加载插件菜单
- Public Sub LoadPluginsMenu()
- Dim i& ', ub&, tstr$
- Dim tIndex&
- Dim tAddedCount&
- If pMnu_Plugins Is Nothing Then
- Else
- gODrawMenu.RemoveMulODMenu "plugin"
- gODrawMenu.GetImgLstObj2("plugin2", True).Create 16, 16
- With pMnu_Plugins
- .ClearItems
- tAddedCount = 0
- If gPluginCnt > 0 Then
- For i = 1 To gPluginCnt
- If gPlugins(i).VisInMenu = 1 Then
- tAddedCount = tAddedCount + 1
- .Add gPlugins(i).Title, , i + IdOffset_Plugins
- tIndex = gODrawMenu.GetImgLstObj("plugin2").AddIcon(GetPluginIcon(gPlugins(i)), True)
- If tIndex >= 0 Then
- gODrawMenu.RstMenu .hWnd, i + IdOffset_Plugins, _
- , tIndex, , , 0, "plugin", "plugin2"
- Else
- gODrawMenu.RstMenu .hWnd, i + IdOffset_Plugins, , gPlugins(i).GetModuleTypeIndex, , , 0, "plugin", "plugin"
- End If
- End If
- Next i
- If tAddedCount = 0 Then
- .Add "(空)", pmsString Or pmsDisabled
- End If
- Else
- .Add "(空)", pmsString Or pmsDisabled
- End If
- .Add "", pmsSeparator
- .Add "下载批量文件(flashget)...", , IDM_Main_OuterTools_FlashgetDownload
- End With
- End If
- End Sub
- Private Function GetPluginIcon(vPObj As cPluginData) As Long
- Dim tModuleType&
- tModuleType = vPObj.GetModuleTypeIndex
- If vPObj.IconFile = vbNullString Then
- Select Case tModuleType
- Case 1, 2, 3
- GetPluginIcon = ExtraIconVb(vPObj.Get_O_FileName, 0)
- Case 0
- GetPluginIcon = 0
- End Select
- Else
- ' Debug.Print "iconfile", GetFileFolder(vPObj.FileName) & "" & vPObj.IconFile
- GetPluginIcon = ExtraIconVb(vPObj.GetRealFileFolder & "" & vPObj.IconFile, 0)
- End If
- End Function
- '
- '---------------------------------------------------------------------------------------
- ' Procedure : LoadPlugins_SideBand
- ' DateTime : 2005-5-29 21:06
- ' Author : Lingll
- ' Purpose : 加载边栏插件菜单,及装载dll
- '---------------------------------------------------------------------------------------
- Public Sub LoadPlugins_SideBand()
- Dim i& ', ub&, tstr$
- Dim tIndex&
- Dim tAddedCount&
- If pMnu_Plugins Is Nothing Then
- Else
- With pMnu_ViewSideBand
- .ClearItems
- .Add "收藏夹(&F)", , IDM_Main_View_SideBand_Favorite
- If gPluginSBCnt > 0 Then
- tAddedCount = 0
- For i = 1 To gPluginSBCnt
- If gPluginsSideBand(i).VisInMenu = 1 Then
- gPluginsSideBand(i).LoadSideBand
- gPluginsSideBand(i).SetSite gMainForm.SideBandParentHwnd
- gMainForm.SetSidebandSize gPluginsSideBand(i)
- tAddedCount = tAddedCount + 1
- .Add gPluginsSideBand(i).Title, , i + IdOffset_ViewSideBand
- End If
- Next i
- If tAddedCount > 0 Then
- .Add2 "", 1, True, pmsSeparator
- End If
- End If
- End With
- End If
- End Sub
- 'Public Sub ReadPluginData(vFile$, vPlgDat As PluginData)
- 'Dim tIni As cINIFile
- '
- 'Set tIni = New cINIFile
- 'tIni.IniFile = vFile
- '
- 'vPlgDat.o_FileName = tIni.ReadKey("General", "FileName")
- 'vPlgDat.o_Title = tIni.ReadKey("General", "Title")
- 'vPlgDat.ModuleType = LCase(tIni.ReadKey("General", "ModuleType"))
- 'Select Case vPlgDat.ModuleType
- ' Case "script"
- ' Call Plugin_LoadScript(tIni, vPlgDat)
- ' Case "exe"
- ' vPlgDat.Data_Exe.Param = tIni.ReadKey("Exe", "Param")
- ' Case "com"
- ' vPlgDat.Data_Com.ClassID = tIni.ReadKey("Com", "ClassID")
- ' vPlgDat.Data_Com.ObjectName = tIni.ReadKey("Com", "ObjectName")
- ' Case "dll"
- '
- 'End Select
- '
- 'End Sub
- '
- '
- '
- ''读取脚本文件
- 'Private Sub Plugin_LoadScript(vIni As cINIFile, vPlgDat As PluginData)
- 'Dim tFN&
- '
- 'With vIni
- ' vPlgDat.Data_Script.Language = .ReadKey("Script", "Language", "javascript")
- ' vPlgDat.Data_Script.LoadedScript = False
- ' vPlgDat.Data_Script.RunType = Val(.ReadKey("Script", "RunType", "0"))
- ' vPlgDat.Data_Script.LoadAtExec = Val(.ReadKey("Script", "LoadAtExec", "0"))
- 'End With
- '
- 'If vPlgDat.Data_Script.LoadAtExec <> 0 Then
- ' tFN = FreeFile
- ' Open vPlgDat.o_FileName For Binary As tFN
- ' vPlgDat.Data_Script.Script = StrConv(InputB(LOF(tFN), tFN), vbUnicode)
- ' Close tFN
- '
- ' vPlgDat.Data_Script.LoadedScript = True
- 'End If
- '
- 'End Sub
- ''运行时才加载脚本文件的sub
- 'Public Sub LoadScriptFile2(nScript As ScriptData)
- 'On Error GoTo due
- 'Dim tFN&, tPos&
- 'Dim tstr$
- '
- 'tFN = FreeFile
- 'Open nScript.FileName For Binary As tFN
- ' tstr = StrConv(InputB(LOF(tFN), tFN), vbUnicode)
- 'Close tFN
- '
- 'tPos = InStr(1, tstr, ScriptInfoFlag_Script)
- 'If tPos > 0 Then
- ' nScript.Script = mID(tstr, tPos + Len(ScriptInfoFlag_Script))
- 'End If
- 'nScript.LoadedScript = True
- '
- 'Exit Sub
- '
- 'due:
- ' Reset
- ' nScript.LoadedScript = False
- ' nScript.Script = ""
- ' Debug.Print "loadscriptfile2", Err.Description
- 'End Sub