[edit] Update - I was shocked to learn that in 2015 the Purebasic forum search engine is so useless it failed to miss the 23 actual instances it shouldve found! lol! what a waste of time ... must use Google search from now on!
Im only using small 512 byte buffer though, if youre expecting larger values/data you might want to increase that! You can check the return value of RegEnumValue for that.
Code: Select all
Procedure EnumRegValues(RootHKEY.l, sKey.s)
Protected hKey.l
If RegOpenKeyEx_(RootHKEY, sKey, 0, #KEY_READ, @hKey) = #ERROR_SUCCESS
idx.l = 0
Repeat
ValueName.s = Space(511): ValueNameLen.l = Len(ValueName)
ValueData.s = Space(511): ValueDataLen.l = Len(ValueData)
Retval.l = RegEnumValue_(hKey, idx, @ValueName, @ValueNameLen, #Null, @dwType, @ValueData, @ValueDataLen)
If Retval <> #ERROR_SUCCESS
Break
EndIf
ValueName = Left(ValueName, ValueNameLen)
Select dwType
Case #REG_SZ
ValueData = Left(ValueData, ValueDataLen - 1)
Default
ValueData = "<Not REG_SZ>"
EndSelect
Debug(ValueName + " = " + ValueData)
idx = idx + 1
Until Retval <> #ERROR_SUCCESS
RegCloseKey_(hKey)
Else
Debug("RegOpenKeyEx fail")
EndIf
EndProcedure
EnumRegValues(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion")