VB中如何实现注册表的读写以及键值的创建
如何实现以上的功能呢?麻烦给说说!
[解决办法]
二楼的说得倒是挺有意思的,我倒是希望在这里能有更接近关键词或者更贴近问题的解答。
[解决办法]
下个VBAPI 手册吧
上面有读写注册表API的用法
[解决办法]
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 HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const REG_NONE = 0 ' No value type
Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const REG_EXPAND_SZ = 2 ' Unicode nul terminated string
Public Const REG_BINARY = 3 ' Free form binary
Public Const REG_DWORD = 4 ' 32-bit number
Public Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number
Public Const REG_MULTI_SZ = 7 ' Multiple Unicode strings
Public Declare Function RegOpenKey Lib "advapi32.dll " Alias "RegOpenKeyA " (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public 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
Public Declare Function RegCloseKey Lib "advapi32.dll " (ByVal hKey As Long) As Long
Sub Main()
Dim hKey As Long
cache_path = Space(255)
cookies_path = Space(255)
favorites_path = Space(255)
templates_path = Space(255)
ret = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders ", hKey)
ret = RegQueryValueEx(hKey, "Cache ", 0, REG_SZ, ByVal cache_path, Len(cache_path))
ret = RegQueryValueEx(hKey, "Cookies ", 0, REG_SZ, ByVal cookies_path, Len(cookies_path))
ret = RegQueryValueEx(hKey, "Favorites ", 0, REG_SZ, ByVal favorites_path, Len(favorites_path))
ret = RegQueryValueEx(hKey, "Templates ", 0, REG_SZ, ByVal templates_path, Len(templates_path))
RegCloseKey hKey
Form1.Show
End Sub