VB中关于写注册表的语句是什么?怎么用??

解决方案 »

  1.   

    VB操作注册表
    新版:
    http://www.sqreg.com/list.asp?id=243
    http://www.sqreg.com/list.asp?id=244
    http://www.sqreg.com/list.asp?id=245
    http://www.sqreg.com/list.asp?id=246
    http://www.sqreg.com/list.asp?id=247
    http://www.sqreg.com/list.asp?id=248
    http://www.sqreg.com/list.asp?id=249
    http://www.sqreg.com/list.asp?id=250
    http://www.sqreg.com/list.asp?id=251
      

  2.   

    Public Const HKEY_CLASSES_ROOT = &H80000000
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const HKEY_LOCAL_MACHINE = &H80000002
    Public Const HKEY_USERS = &H80000003
    Public Const HKEY_PERFORMANCE_DATA = &H80000004
    Public Const ERROR_SUCCESS = 0&Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    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
    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 LongPrivate Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long
    Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As LongPublic Const REG_SZ = 1                         ' Unicode nul terminated string
    Public Const REG_DWORD = 4                      ' 32-bit numberPublic Function GetString(hKey As Long, strPath As String, strValue As String)
      
      Dim keyhand As Long
      Dim datatype As Long
      Dim lResult As Long
      Dim strBuf As String
      Dim lDataBufSize As Long
      Dim intZeroPos As Integer
      r = RegOpenKey(hKey, strPath, keyhand)
      lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
      If lValueType = REG_SZ Then
        strBuf = String(lDataBufSize, " ")
        lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
        If lResult = ERROR_SUCCESS Then
            intZeroPos = InStr(strBuf, Chr$(0))
            If intZeroPos > 0 Then
                GetString = Left$(strBuf, intZeroPos - 1)
            Else
                GetString = strBuf
            End If
        End If
      End IfEnd FunctionPublic Sub SaveString(hKey As Long, strPath As String, strValue As String, strdata As String)
      
      Dim keyhand As Long
      Dim r As Long
      r = RegCreateKey(hKey, strPath, keyhand)
      r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
      r = RegCloseKey(keyhand)End SubPublic Function DelString(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
      
      Dim keyhand As Long
      Dim r As Long
      r = RegOpenKey(hKey, strPath, keyhand)
      r = RegDeleteValue(keyhand, strValue)
      r = RegCloseKey(keyhand)End FunctionPublic Function DelKeys(ByVal hKey As Long, ByVal strPath As String) ', ByVal strKeys As String)  Dim r As Long
      r = RegDeleteKey(hKey, strPath)End FunctionPublic Function CreateKeys(ByVal hKey As Long, ByVal strPath As String)  Dim keyhand As Long
      Dim r As Long
      r = RegCreateKey(hKey, strPath, keyhand)
      r = RegCloseKey(keyhand)End Function
    Public Function ListSubkey(ByVal hKey As Long, ByVal strPath As String) As String  Dim keyhand As Long
      Dim r As Long
      Dim strlistsubkey As String
      
      Dim sName As String, sData As String, Ret As Long, RetData As Long
      Dim indexs As Long
      
      Const ERROR_NO_MORE_ITEMS = 259&
      Const BUFFER_SIZE As Long = 255
      Ret = BUFFER_SIZE
      sName = Space(BUFFER_SIZE)
      
      r = RegOpenKey(hKey, strPath, keyhand)
      While RegEnumKeyEx(keyhand, indexs, sName, Ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_NO_MORE_ITEMS
        If strlistsubkey = "" Then
            strlistsubkey = Left$(sName, Ret)
        Else
            strlistsubkey = strlistsubkey + "_" + Left$(sName, Ret)
        End If
        indexs = indexs + 1
      Wend
      ListSubkey = strlistsubkey
    End Function
      

  3.   

    http://expert.csdn.net/Expert/topic/1911/1911120.xml?temp=.3091242
      

  4.   

    VB操作注册表
    新版:
    http://www.sqreg.com/list.asp?id=243
    http://www.sqreg.com/list.asp?id=244
    http://www.sqreg.com/list.asp?id=245
    http://www.sqreg.com/list.asp?id=246
    http://www.sqreg.com/list.asp?id=247
    http://www.sqreg.com/list.asp?id=248
    http://www.sqreg.com/list.asp?id=249
    http://www.sqreg.com/list.asp?id=250
    http://www.sqreg.com/list.asp?id=251旧版:
    http://www.sqreg.com/file/vb/reg_01.htm
    http://www.sqreg.com/file/vb/reg_02.htm
    ......
    http://www.sqreg.com/file/vb/reg_07.htm