如何用程序操纵注册表呀?有没有例子?~

解决方案 »

  1.   

    RegCreateKey
    ....
    查看MSDN中Reg...开头的 函数,MSDN有很详细的Sample Code
    也可以用Shell的以SHReg开头的函数,操作要方便一点
      

  2.   

    '读注册表
    Public Function GetSetting(pszSection As String, pszKey As String, Optional pszDefValue As String = "") As String
        Dim lCount As Long
        Dim szValue As String
        Dim lHandle As Long
        Dim szType As String
        Dim szTemp As String    szType = "REG_SZ"
        lCount = 2001
        szValue = Space(2002)
        
        szTemp = "Root=" & m_lRoot & " AppName=" & m_szAppName & " SubKey=" & m_szSubKey & " Section=" & pszSection & " Key=" & pszKey & " Default=" & pszDefValue    On Error GoTo Error_Handle
        lHandle = GetTop(pszSection, False)
        
        ShowError (RegQueryValueEx(lHandle, pszKey, &O0, &O0, szValue, lCount))
        ShowError (RegCloseKey(lHandle))
        If lCount > 0 Then
            szValue = StrConv(szValue, vbFromUnicode)
            GetSetting = StrConv(LeftB(szValue, lCount - 1), vbUnicode)
        Else
            GetSetting = pszDefValue
        End If
        Exit FunctionError_Handle:
        GetSetting = pszDefValueEnd Function'写注册表
    Public Sub SaveSetting(pszSection As String, pszKey As String, pszValue As String)
        Dim lCount As Long
        Dim lResult As Long
        Dim lHandle As Long
        AssertRootValid
        lCount = LenB(StrConv(pszValue, vbFromUnicode))
        lHandle = GetTop(pszSection)
       
        ShowError (RegSetValueEx(lHandle, pszKey, &O0, REG_SZ, pszValue, lCount))
        ShowError (RegCloseKey(lHandle))
    End Sub
      

  3.   

    http://www.vckbase.com/code/listcode.asp?mclsid=13&sclsid=1317里全是注册表操作的例子,看看就明白了。