Kan någon hjälpa med med en fungerande kod för att läsa värdet på detta registervärde och sen lägga det i varialbel? Behöver nog tyvärr en helt fungerande kod... <code> Ett enkelt sätt är om du sätter en referens till Windows Script Host Object Model sen är det bara att köra typ:Registerhjälp
hkey_current_user\software\Microsoft\Windows\CurrentVersion\Explorer\Shell folders\recent
jag har inte lyckats.
/EmilSv: Registerhjälp
Option Explicit
'Dessa deklarationer behövs för funktionen Kollaregister
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004
Const ERROR_SUCCESS = 0&
Const REG_SZ = 1
Const REG_DWORD = 4
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
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 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
Private 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 Long
Public 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
Dim r, lValueType
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 If
End Function
Public 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 Sub
Private Sub Form_Load()
Dim Lib As String
Dim RegVärde As String
Lib = "software\Microsoft\Windows\CurrentVersion\Explorer\Shell folders"
'För att läsa värdet på "Recent"
RegVärde = GetString(HKEY_CURRENT_USER, Lib, "recent")
'För att sätt nytt värde på "Recent"
SaveString HKEY_CURRENT_USER, Lib, "recent", RegVärde
End Sub
</code>
Lycka till
AZSv: Registerhjälp
Dim Wsh As New WshShell
MsgBox Wsh.RegRead("HKEY_CURRENT_USER\software\Microsoft\Windows\CurrentVersion\Explorer\Shell folders\recent")
Set Wsh = Nothing
Lika enkelt att skriva till registret också. Lägg bara till värdet sist och byt till RegWrite
Mvh Leif P