Registry girişine almak ve kaydetmek
‘girişe yazınız.
‘ HKEY_CURRENT_USER\Software\VB and VBA Program Settings\MyApp\Settings\
SaveSetting "MyApp", "Settings", "Left", 10
‘Debug penceresinden giriş ve çıkışları oku.
Debug.Print GetSetting("MyApp", "Settings", "Left", 4)
Registry’de Windows API kullanımı
Option Explicit
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias _
"RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, _
phkResult As Long) As Long
Private Declare Function RegQueryValueExStr Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As _
String, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As _
Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_SZ = 1&
Private Sub Command1_Click()
Dim hKey As Long
Dim lRet As Long, lenData As Long
Dim sSubKey As String, sData As String
sSubKey = "Control Panel\Colors\"
lRet = RegOpenKey(HKEY_CURRENT_USER, sSubKey, hKey)
lenData = 255
sData = Space$(lenData)
lRet = RegQueryValueExStr(hKey, "ButtonFace", 0, REG_SZ, _
sData, lenData)
sData = Left$(lenData)
Debug.Print "The value is: " & sData
lRet = RegCloseKey(hKey)
End Sub