xizor
asked on
Reading Local Users Registry & Closing Registry Afterwards
I want to read settings out of the other local users registry's on the local PC. I dont know if this is the best way but its the only way i've found so far and i cant seem to get regloadkey to work:
Firstly I run a shell command:
REG load HKLM\TempData "F:\Documents and Settings\Test\ntuser.dat"
This loads the user hive into a tempory key called TempData under HKLM
I can now read all the settings i want from it.
when I am finished with that users hive, i need to unload it to load another the shell command is:
reg unload HKLM\TempData
when I run this is returns:
Error: Â Access is denied.
and I can not unload the hive until i quit VB6.
Perhaps I am not closing my keys properly? or somthing else?
The code i am using for reading the registry keys is:
Public Declare Function RegQueryValueEx 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
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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const REG_SZ = 1
Public Const LOCALMACHINE = &H80000002
nBufferData = Space(256)
RegOpenKey LOCALMACHINE, MainKey, nBufferKey
RegOpenKey nBufferKey, SubKey, nBufferSubKey
RegQueryValueEx nBufferSubKey, RegItem, 0, REG_SZ, nBufferData, Len(nBufferData)
RegCloseKey LOCALMACHINE
Any Ideas on any of this anyone?
Firstly I run a shell command:
REG load HKLM\TempData "F:\Documents and Settings\Test\ntuser.dat"
This loads the user hive into a tempory key called TempData under HKLM
I can now read all the settings i want from it.
when I am finished with that users hive, i need to unload it to load another the shell command is:
reg unload HKLM\TempData
when I run this is returns:
Error: Â Access is denied.
and I can not unload the hive until i quit VB6.
Perhaps I am not closing my keys properly? or somthing else?
The code i am using for reading the registry keys is:
Public Declare Function RegQueryValueEx 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
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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const REG_SZ = 1
Public Const LOCALMACHINE = &H80000002
nBufferData = Space(256)
RegOpenKey LOCALMACHINE, MainKey, nBufferKey
RegOpenKey nBufferKey, SubKey, nBufferSubKey
RegQueryValueEx nBufferSubKey, RegItem, 0, REG_SZ, nBufferData, Len(nBufferData)
RegCloseKey LOCALMACHINE
Any Ideas on any of this anyone?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.