默认浏览器的注册密钥 [英] registery key for default browser

查看:72
本文介绍了默认浏览器的注册密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iv发现一个代码将我的浏览器设置为疯狂的默认浏览器

遗憾的是这是一个vb6模块代码]



code :

iv found a code to set my browser i mad as the default browser
unfortunately this is a vb6 module code]

code:

    Const REG_SZ As Long = 1
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const KEY_SET_VALUE = &H2
    Const KEY_ALL_ACCESS = &H3F
    Const REG_OPTION_NON_VOLATILE = 0
    Const HWND_BROADCAST = &HFFFF
    Const WM_SETTINGCHANGE = &H1A



    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey 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, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
    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 RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As String) As Long
Public Function SetClient(iClient As Integer, sDisplayName As String,   sClientCommandLine As String, sClientResourceDLL As String,   iLocalization As Integer, bGlobalClient As Boolean,   Optional sCLParameters As String, Optional bMakeDefault As Boolean) As Integer

        ' iClient - 1 for internet browser, 2 for e-mail client
        ' sDisplayName - the name to be displayed on the menu for the client
        ' sClientCommandLine - the path and filename of the e-mail client
        '
        ' The next two parameters are included for localization of the client.
        ' For backwards compatibility with applications that do not support localized
        ' strings, the name of the application in the installed language should be set
        ' as the Default value for the key.
        ' sClientResourceDLL - provides a path to an EXE or DLL containing the
        '   localized strings for the client.
        ' iLocalization - a string resource ID within the DLL whose value is
        '   to be displayed to the user allowing the same registration to
        '   be used for multiple languages.  For each language, provide a
        '   different Resource DLL, and the dynamic loading of the string
        '   from the DLL results in the correct strings being displayed, depending
        '   on the language.
        '
        ' bGlobalClient - sets the value for either all users (True) or the
        '   current user (False)
        ' sCLParameters - additional parameters on the command line to be passed to the
        '   browser or e-mail client.
        ' bMakeDefault - (Optional) set the browser or e-mail application as the default

        Dim iStatus As Integer
        Dim hHandle As Long
        Dim hGRegKey As String
        Dim hLRegKey As String
        Dim sCommand As String
        Dim sKey As String
        Dim sAll As String
        Dim sRoot As String
        Dim hKey As Long
        Dim sLoc As String
        hGRegKey = HKEY_LOCAL_MACHINE
        hLRegKey = HKEY_CURRENT_USER


        If iClient = 1 Then
            sRoot = "Software\Clients\StartMenuInternet"
        Else
            sRoot = "Software\Clients\Mail"
        End If

        ' Create and null terminate needed strings
        sCommand = "shell\open\command"
        sKey = sRoot & "\" & sDisplayName
        sAll = sKey & "\" & sCommand
        sLoc = "@" & sClientResourceDLL & "," & iLocalization & Chr$(0)'<-- error
        sClientLocation_ '<-- error
 = """" & sClientCommandLine & """" & IIf(sCLParameters <> "", " ", "") & Trim(sCLParameters) & Chr$(0) '<-- error
        sDisplayName = sDisplayName & Chr$(0)'<-- error

        ' Create a registry key for the new client
        iStatus = RegCreateKeyEx(hGRegKey, sKey, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
        iStatus = RegCreateKeyEx(hGRegKey, sAll, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
        If iStatus = ERROR_NONE Then '<-- error
            iStatus = RegOpenKeyEx(hGRegKey, sAll, 0, KEY_SET_VALUE, hKey)
            iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sClientLocation,_ '<-- error 
Len(sClientLocation))'<-- error
            iStatus = RegCloseKey(hKey)
            iStatus = RegOpenKeyEx(hGRegKey, sKey, 0, KEY_SET_VALUE, hKey)
            iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sDisplayName, Len(sDisplayName))
            ' Add the localization string
            iStatus = RegSetValueExString(hKey, "LocalizedString", 0&, REG_SZ, sLoc, Len(sLoc))
            iStatus = RegCloseKey(hKey)
        Else
            SetClient = iStatus
            Exit Function
        End If

        '  Sets browser as local or global default if specified
        If bMakeDefault Then
            If bGlobalClient Then
                iStatus = RegOpenKeyEx(hGRegKey, sRoot, 0, KEY_SET_VALUE, hKey)
                iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sDisplayName, Len(sDisplayName))
                iStatus = RegCloseKey(hKey)
            Else
                iStatus = RegCreateKeyEx(hLRegKey, sRoot, 0&, vbNullString REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey,_ '<-- error
 lRetVal)
                iStatus = RegSetValueExString(hNewKey,_ '<-- error
 "", 0&, REG_SZ, sDisplayName, Len(sDisplayName))
                iStatus = RegCloseKey(hNewKey)
            End If
            UpdateMenus()
        End If
    End Function
    Private Sub UpdateMenus()
        ' Refresh the menu choices with the updated client
        Dim iRetVal As Integer
        iRetVal = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "SOFTWARE\Clients\mail")
        iRetVal = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "SOFTWARE\Clients\StartMenuInternet")
    End Sub





我的问题是:我如何转换它。

请帮助我!!



Bart de Lange



my qestion is: how do i convert it.
please help me!!

Bart de Lange

推荐答案

0 ' < - error
sClientLocation_ ' < - error
= & sClientCommandLine& & IIf(sCLParameters<> ) &安培;修剪(sCLParameters)& Chr
(0)'<-- error sClientLocation_ '<-- error = """" & sClientCommandLine & """" & IIf(sCLParameters <> "", " ", "") & Trim(sCLParameters) & Chr


0 ' < - 错误
sDisplayName = sDisplayName& Chr
(0) '<-- error sDisplayName = sDisplayName & Chr


0 ' < - 错误

' 创建注册表项对于新客户
iStatus = RegCreateKeyEx(hGRegKey,sKey,0&,vbNullString,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0&,hNewKey,lRetVal)
iStatus = RegCreateKeyEx(hGRegKey,sAll,0& ,vbNullString,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0&,hNewKey,lRetVal)
如果 iStatus = ERROR_NONE 那么 ' < - error
iStatus = RegOpenKeyEx(hGRegKey,sAll, 0 ,KEY_SET_VALUE,hKey)
iStatus = RegSetValueExString(hKey, ,0& ;, REG_SZ,sClientLocation,_ ' < - 错误
Len(sClientLocation))' < - error
iStatus = RegCloseKey(hKey)
iStatus = RegOpenKeyEx( hGRegKey,sKey, 0 ,KEY_SET_VALUE,hKey)
iStatus = RegSetValueExString(hKey, < span class =code-string>,0&,REG_SZ,sDisplayName,Len(sDisplayName))
' 添加本地化字符串
iStatus = RegSetValueExString(hKey, LocalizedString ,0&,REG_SZ,sLoc,Len(sLoc))
iStatus = RegCloseKey(hKey)
其他
SetClient = iStatus
退出 功能
结束 如果

' 将浏览器设置为本地或全局默认值指定
如果 bMakeDefault 那么
如果 bGlobalClient 那么
iStatus = RegOpenKeyEx(hGRegKey,sRoot, 0 ,KEY_SET_VALUE,hKey)
iStatus = RegSetValueExString(hKey, ,0& ,REG_SZ,sDisplayName,Len(sDisplayName))
iStatus = RegCloseKey(hKey)
否则
iStatus = RegCreateKeyEx(hLRegKey,sRoot) ,0&,vbNullString REG_OPTION_N ON_VOLATILE,KEY_ALL_ACCESS,0&,hNewKey,_ ' < - 错误
lRetVal)
iStatus = RegSetValueExString(hNewKey,_ ' < - error
< span class =code-string> ,0&,REG_SZ,sDisplayName,Len(sDisplayName))
iStatus = RegCloseKey( hNewKey)
结束 如果
UpdateMenus()
结束 如果
结束 功能
私有 Sub UpdateMenus()
' 使用更新的客户端刷新菜单选项
Dim iRetVal 作为 整数
iRetVal = SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE, 0 SOFTWARE\Clients\mail
iRetVal = SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE, 0 SOFTWARE \Clients \StartMenuInternet
结束 Sub
(0)'<-- error ' Create a registry key for the new client iStatus = RegCreateKeyEx(hGRegKey, sKey, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal) iStatus = RegCreateKeyEx(hGRegKey, sAll, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal) If iStatus = ERROR_NONE Then '<-- error iStatus = RegOpenKeyEx(hGRegKey, sAll, 0, KEY_SET_VALUE, hKey) iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sClientLocation,_ '<-- error Len(sClientLocation))'<-- error iStatus = RegCloseKey(hKey) iStatus = RegOpenKeyEx(hGRegKey, sKey, 0, KEY_SET_VALUE, hKey) iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sDisplayName, Len(sDisplayName)) ' Add the localization string iStatus = RegSetValueExString(hKey, "LocalizedString", 0&, REG_SZ, sLoc, Len(sLoc)) iStatus = RegCloseKey(hKey) Else SetClient = iStatus Exit Function End If ' Sets browser as local or global default if specified If bMakeDefault Then If bGlobalClient Then iStatus = RegOpenKeyEx(hGRegKey, sRoot, 0, KEY_SET_VALUE, hKey) iStatus = RegSetValueExString(hKey, "", 0&, REG_SZ, sDisplayName, Len(sDisplayName)) iStatus = RegCloseKey(hKey) Else iStatus = RegCreateKeyEx(hLRegKey, sRoot, 0&, vbNullString REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey,_ '<-- error lRetVal) iStatus = RegSetValueExString(hNewKey,_ '<-- error "", 0&, REG_SZ, sDisplayName, Len(sDisplayName)) iStatus = RegCloseKey(hNewKey) End If UpdateMenus() End If End Function Private Sub UpdateMenus() ' Refresh the menu choices with the updated client Dim iRetVal As Integer iRetVal = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "SOFTWARE\Clients\mail") iRetVal = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "SOFTWARE\Clients\StartMenuInternet") End Sub





我的问题是:我如何转换它。

请帮帮我!!



Bart de Lange



my qestion is: how do i convert it.
please help me!!

Bart de Lange


这篇关于默认浏览器的注册密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆