' Add Reference to your Application in Internet Explorer's Tools Menu + Icon on Toolbar (VER. 5.0 or Higher)
' Copyright ゥ 2000 Chuck DeLong
'******************************
' VERSION 2.0
'
'Further info on Browser Extensions can be found at...
'http://msdn.microsoft.com/workshop/browser/ext/overview/overview.asp
'
' Registry Functions By:
'*******************************************************************************
' Project: General Functions
' Program: Registry Functions
' Author: V.A. van den Braken
' Version: 1.1
' Date: 30-07-1997, 02-08-1997
' Copyright: Copyright ゥ 1997 Deltec BV, Naarden
' Description: Functions to access/modify/write the Windows Registry
'*******************************************************************************
'
' Menustat sample from BlackBeltVB.com
' http://blackbeltvb.com
'
' Written by Matt Hart
' Copyright 1999 by Matt Hart
'
' *IMPORTANT*
' Make sure you compile into an exe, then run the exe (Running in design mode will reference IETOOLS.vbp instead of SampleApp.exe and MSIE will not find an *.exe to run!)
' A new instance of MSIE is required for changes to be seen (Add or Delete)
'
Option Explicit
' Shlwapi.dll (MSIE Version Info) (All required...)
Type DllVersionInfo
cbSize As Long
dwMajorVersion As Long '...But the only one we need
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformID As Long
End TypeDeclare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As DllVersionInfo) As LongDim IEMV As DllVersionInfo
Dim CheckReg As String
Dim GetIEMajor As String
Dim Hico As String
Dim Ico As String
Dim Prog As StringPublic Function DetectIE()
'See Res in Private Sub Form_Load()
CheckReg = REGGetSetting(vHKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE", "")
IEMV.cbSize = Len(IEMV)
Call DllGetVersion(IEMV)
GetIEMajor = IEMV.dwMajorVersion
If Dir(CheckReg) = "" Or GetIEMajor < 5 Then
Else
CheckReg = REGGetSetting(vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "CLSID")
End If
End FunctionPublic Function mnuAddIE()
' Path of yor App and HotIcon
Hico = App.Path & "\" & "hoticon.ico"
' Path of yor App and Icon
Ico = App.Path & "\" & "icon.ico"
' Path of yor App and Apps *.exe name
Prog = App.Path & "\" & App.EXEName
' Adds your App to MSIE's Tools Menu and adds an Icon on the Toolbar
' {ECC5777A-6E88-BFCE-13CE-81F134789E7B} Any GUID
' Your App (Tools Menu Button Text)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "ButtonText", "Your App"
' {1FBA04EE-3024-11D2-8F1F-0000F87ABD16} MUST BE THIS GUID
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "CLSID", "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}"
' Show Icon if IE Toolbar is reset
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Default Visible", "Yes"
' Your APP Path and Name (Prog)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Exec", Prog
' Colered icon (Hico)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "HotIcon", Hico
' Default icon (Ico)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Icon", Ico
'Statusbar text for your App
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "MenuStatusBar", "Your App"
'Tools Menu text for your APP
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "MenuText", "&Your App"
Form1.mnuAddMSIE.Enabled = False
Form1.mnuDeleteMSIE.Enabled = True
End FunctionPublic Function mnuDeleteIE()
' Deletes your App in MSIE's Tools Menu and the Icon on the Toolbar
REGDeleteSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}"
End Function
回复人: ozw(沧浪客) (2001-8-21 18:59:16) 得0分
'*******************************************************************************
' Project: General Functions
' Program: Registry Functions
' Author: V.A. van den Braken
' Version: 1.1
' Date: 30-07-1997, 02-08-1997
' Copyright: Copyright ゥ 1997 Deltec BV, Naarden
' Description: Functions to access/modify/write the Windows Registry
'*******************************************************************************
Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal HKEY As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal HKEY As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, phkResult As Long, lpdwDisposition As Long) As Long
'Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal HKEY As Long, ByVal lpValueName As String) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As LongEnum HKEYS
vHKEY_CLASSES_ROOT = &H80000000
vHKEY_CURRENT_USER = &H80000001
vHKEY_LOCAL_MACHINE = &H80000002
vHKEY_USERS = &H80000003
vHKEY_PERFORMcANCE_DATA = &H80000004
vHKEY_CURRENT_CONFIG = &H80000005
vHKEY_DYN_DATA = &H80000006
End Enum
' Copyright ゥ 2000 Chuck DeLong
'******************************
' VERSION 2.0
'
'Further info on Browser Extensions can be found at...
'http://msdn.microsoft.com/workshop/browser/ext/overview/overview.asp
'
' Registry Functions By:
'*******************************************************************************
' Project: General Functions
' Program: Registry Functions
' Author: V.A. van den Braken
' Version: 1.1
' Date: 30-07-1997, 02-08-1997
' Copyright: Copyright ゥ 1997 Deltec BV, Naarden
' Description: Functions to access/modify/write the Windows Registry
'*******************************************************************************
'
' Menustat sample from BlackBeltVB.com
' http://blackbeltvb.com
'
' Written by Matt Hart
' Copyright 1999 by Matt Hart
'
' *IMPORTANT*
' Make sure you compile into an exe, then run the exe (Running in design mode will reference IETOOLS.vbp instead of SampleApp.exe and MSIE will not find an *.exe to run!)
' A new instance of MSIE is required for changes to be seen (Add or Delete)
'
Option Explicit
' Shlwapi.dll (MSIE Version Info) (All required...)
Type DllVersionInfo
cbSize As Long
dwMajorVersion As Long '...But the only one we need
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformID As Long
End TypeDeclare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As DllVersionInfo) As LongDim IEMV As DllVersionInfo
Dim CheckReg As String
Dim GetIEMajor As String
Dim Hico As String
Dim Ico As String
Dim Prog As StringPublic Function DetectIE()
'See Res in Private Sub Form_Load()
CheckReg = REGGetSetting(vHKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE", "")
IEMV.cbSize = Len(IEMV)
Call DllGetVersion(IEMV)
GetIEMajor = IEMV.dwMajorVersion
If Dir(CheckReg) = "" Or GetIEMajor < 5 Then
Else
CheckReg = REGGetSetting(vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "CLSID")
End If
End FunctionPublic Function mnuAddIE()
' Path of yor App and HotIcon
Hico = App.Path & "\" & "hoticon.ico"
' Path of yor App and Icon
Ico = App.Path & "\" & "icon.ico"
' Path of yor App and Apps *.exe name
Prog = App.Path & "\" & App.EXEName
' Adds your App to MSIE's Tools Menu and adds an Icon on the Toolbar
' {ECC5777A-6E88-BFCE-13CE-81F134789E7B} Any GUID
' Your App (Tools Menu Button Text)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "ButtonText", "Your App"
' {1FBA04EE-3024-11D2-8F1F-0000F87ABD16} MUST BE THIS GUID
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "CLSID", "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}"
' Show Icon if IE Toolbar is reset
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Default Visible", "Yes"
' Your APP Path and Name (Prog)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Exec", Prog
' Colered icon (Hico)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "HotIcon", Hico
' Default icon (Ico)
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "Icon", Ico
'Statusbar text for your App
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "MenuStatusBar", "Your App"
'Tools Menu text for your APP
REGSaveSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}", "MenuText", "&Your App"
Form1.mnuAddMSIE.Enabled = False
Form1.mnuDeleteMSIE.Enabled = True
End FunctionPublic Function mnuDeleteIE()
' Deletes your App in MSIE's Tools Menu and the Icon on the Toolbar
REGDeleteSetting vHKEY_LOCAL_MACHINE, "Software\Microsoft\Internet Explorer\Extensions\{ECC5777A-6E88-BFCE-13CE-81F134789E7B}"
End Function
回复人: ozw(沧浪客) (2001-8-21 18:59:16) 得0分
'*******************************************************************************
' Project: General Functions
' Program: Registry Functions
' Author: V.A. van den Braken
' Version: 1.1
' Date: 30-07-1997, 02-08-1997
' Copyright: Copyright ゥ 1997 Deltec BV, Naarden
' Description: Functions to access/modify/write the Windows Registry
'*******************************************************************************
Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal HKEY As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal HKEY As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, phkResult As Long, lpdwDisposition As Long) As Long
'Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal HKEY As Long, ByVal lpValueName As String) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As LongEnum HKEYS
vHKEY_CLASSES_ROOT = &H80000000
vHKEY_CURRENT_USER = &H80000001
vHKEY_LOCAL_MACHINE = &H80000002
vHKEY_USERS = &H80000003
vHKEY_PERFORMcANCE_DATA = &H80000004
vHKEY_CURRENT_CONFIG = &H80000005
vHKEY_DYN_DATA = &H80000006
End Enum
Private Const REG_OPTION_NON_VOLATILE As Long = 0 ' Key is preserved when system is rebooted
Private Const SYNCHRONIZE As Long = &H100000
Private Const STANDARD_RIGHTS_ALL As Long = &H1F0000
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_SET_VALUE As Long = &H2
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_CREATE_LINK As Long = &H20
Private Const KEY_ALL_ACCESS As Long = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Private Const ERROR_SUCCESS As Long = 0&
Private Const REG_SZ As Long = 1 ' Unicode nul terminated string
Private Const READ_CONTROL = &H20000
Private Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Private Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Private Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))
'KEY_ALL_ACCESS 'Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, KEY_CREATE_SUB_KEY, KEY_CREATE_LINK, and KEY_SET_VALUE access.
'KEY_CREATE_LINK 'Permission to create a symbolic link.
'KEY_CREATE_SUB_KEY 'Permission to create subkeys.
'KEY_ENUMERATE_SUB_KEYS 'Permission to enumerate subkeys.
'KEY_EXECUTE 'Permission for read access.
'KEY_NOTIFY 'Permission for change notification.
'KEY_QUERY_VALUE 'Permission to query subkey data.
'KEY_READ 'Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY access.
'KEY_SET_VALUE 'Permission to set subkey data.
'KEY_WRITE
'********************************************
' Begin Registry Function
'********************************************
'============================================
' REGDeleteSetting
' Delete Section/Key from Registry
'--------------------------------------------
'
' REGDeleteSetting vHKEY_USERS,"Section"
' Deletes "HKEY_USER\Section\"
' from the registry and all Key and Values under the section
'
' REGDeleteSetting vHKEY_USERS,"Section1\Section2"
' idem but deletes all from "HKEY_USERS\Section1\Section2"
'
' REGDeleteSetting vHKEY_USERS,"Section",Key"
' Deletes "HKEY_USER\Section\Key"
' from the registry and Values under the key
'============================================Public Function REGDeleteSetting(ByVal regHKEY As HKEYS, ByVal sSection As String, Optional ByVal sKey As String) As Boolean
Dim lReturn As Long
Dim HKEY As Long
If Len(sKey) Then
lReturn = RegOpenKeyEx(regHKEY, REGSubKey(sSection), 0&, KEY_ALL_ACCESS, HKEY)
If lReturn = ERROR_SUCCESS Then
If sKey = "*" Then sKey = vbNullString
lReturn = RegDeleteValue(HKEY, sKey)
End If
Else
lReturn = RegOpenKeyEx(regHKEY, REGSubKey(), 0&, KEY_ALL_ACCESS, HKEY)
If lReturn = ERROR_SUCCESS Then
lReturn = RegDeleteKey(HKEY, sSection)
End If
End If
REGDeleteSetting = (lReturn = ERROR_SUCCESS)
End Function
'============================================
' REGGetSetting
' Gets Values from the registry
'--------------------------------------------
'
' REGGetSetting vHKEY_CURRENT_USER,"Section","Key","DefaultStringWhenEmpty"
' Gets Value from "HKEY_CURRENT_USER\Section\Key"
' When empty it returns the omitted default("DefaultStringWhenEmpty")
' or an empty string when no default is specified
'
' REGGetSetting vHKEY_CURRENT_USER,"Section1\Section2","Key","DefaultStringWhenEmpty"
' idem but gets value from "HKEY_CURRENT_USER\Section1\Section2\Key"
'============================================Public Function REGGetSetting(ByVal regHKEY As HKEYS, ByVal sSection As String, ByVal sKey As String, Optional ByVal sDefault As String) As String
Dim lReturn As Long
Dim HKEY As Long
Dim lType As Long
Dim lBytes As Long
Dim sBuffer As String
REGGetSetting = sDefault
'Original
lReturn = RegOpenKeyEx(regHKEY, REGSubKey(sSection), 0&, KEY_ALL_ACCESS, HKEY)
If lReturn = 5 Then 'We hebben geen rechten om hem te openen met KEY_ALL_ACCESS, dus we gaan hem read only openen
lReturn = RegOpenKeyEx(regHKEY, REGSubKey(sSection), 0&, KEY_EXECUTE, HKEY)
End If
If lReturn = ERROR_SUCCESS Then
If sKey = "*" Then
sKey = vbNullString
End If
lReturn = RegQueryValueEx(HKEY, sKey, 0&, lType, ByVal sBuffer, lBytes)
If lReturn = ERROR_SUCCESS Then
If lBytes > 0 Then
sBuffer = Space$(lBytes)
lReturn = RegQueryValueEx(HKEY, sKey, 0&, lType, ByVal sBuffer, Len(sBuffer))
If lReturn = ERROR_SUCCESS Then
REGGetSetting = Left$(sBuffer, lBytes - 1)
End If
End If
End If
End If
End Function
'============================================
' REGSaveSetting
' Save Value to the registry
'--------------------------------------------
'
' REGSaveSetting vHKEY_CURRENT_USER, "Section", "Key", "Test"
' Saves the value "Test" to "HKEY_CURRENT_USER\Section\Key"
' And will create the The Sections if they do not exist
'
' REGSaveSetting vHKEY_CURRENT_USER, "Section1\Section2", "Key", "Test"
' idem but save "to HKEY_CURRENT_USER\Section1\Section2\Key"
'============================================Public Function REGSaveSetting(ByVal regHKEY As HKEYS, ByVal sSection As String, ByVal sKey As String, ByVal sValue As String) As Boolean
Dim lRet As Long
Dim HKEY As Long
Dim lResult As Long
lRet = RegCreateKeyEx(regHKEY, REGSubKey(sSection), 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, HKEY, lResult)
If lRet = ERROR_SUCCESS Then
If sKey = "*" Then sKey = vbNullString
lRet = RegSetValueEx(HKEY, sKey, 0&, REG_SZ, ByVal sValue, Len(sValue))
Call RegCloseKey(HKEY)
End If
REGSaveSetting = (lRet = ERROR_SUCCESS)
End Function
'Deletes "\" after section if therePrivate Function REGSubKey(Optional ByVal sSection As String) As String
If Left$(sSection, 1) = "\" Then
sSection = Mid$(sSection, 2)
End If
If Right$(sSection, 1) = "\" Then
sSection = Mid$(sSection, 1, Len(sSection) - 1)
End If
REGSubKey = sSection
End Function
'********************************************
' End Registry Function
'********************************************