Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API version of GetAllSettings Registry stuff 1

Status
Not open for further replies.

MattSTech

Programmer
Apr 10, 2003
333
0
0
US
Hello All,

Well it is after midnight again and it seems I am stuck...again

I am freshening up a program that was initially written using the GetSetting, SaveSetting and GetAllSettings Junk. I have gotten through the majority of the conversion to API calls with the exception of the GetAllSettings stuff.

The program used GetAllSettings to fill an array with the most recently used file list saved as individual values within a single key. The API version of this (I ASSUME) would have been RegEnumValue. I tried using RegEnumKeyEx to get the number of values within the key then tried to extract the value with no luck.

Any thoughts or direction will certainly be appreciated.

Thank you

Matt
 
I could also limit the list to let's say 5 items and parse through them one by one. Any better suggestions, or athread I may have overlooked?

Thanks

Matt
 
Create a function to add/edit values in the windows registry and pass it in a loop.
 
There is no function which can return all the values in a single call. You need to enumerate the values under a key one-by-one with each function call.

The GetAllSettings function works the same way. It retrieves all values using a loop and returns all the result in the form of an array.

See the following code which enumerates the list of all URLs typed in Internet Explorer address bar. You can change the arguments passed to RegOpenKeyEx function to enumerate some other key of your interest.
___
[tt]
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) 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 Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Const KEY_QUERY_VALUE = &H1
Const ERROR_NO_MORE_ITEMS = 259&
Const REG_SZ = 1

Private Sub Form_Load()
Dim hKey As Long, ret, Index As Long, valType As Long
Dim valName As String, valData As String, lenName As Long, lenData As Long
RegOpenKeyEx HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\TypedURLs", 0, KEY_QUERY_VALUE, hKey
Do
lenName = 1000
valName = Space$(lenName)
lenData = 1000
valData = Space$(lenData)
ret = RegEnumValue(hKey, Index, valName, lenName, 0, valType, ByVal valData, lenData)
If ret = ERROR_NO_MORE_ITEMS Then Exit Do
If valType = REG_SZ Then
valName = Left$(valName, lenName)
valData = Left$(valData, lenData)
Debug.Print valName, valData
End If
Index = Index + 1
Loop
RegCloseKey hKey
End
End Sub[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top