Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegEnumValue only returns the first value
Message
From
23/05/2007 17:11:36
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
RegEnumValue only returns the first value
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Vista
Miscellaneous
Thread ID:
01228066
Message ID:
01228066
Views:
74
Never mind, I found the problem. (Read the instructions Greg!)

Hi all,

I am tring to read all the values from a registry branch using the RegEnumValue API function. The second argument is the position of the value in the branch. But it only see the first value. When attempting to getthe second entry, it reports it is beyond the end of the list. This function work fine yesterday, but stop working sometime today. I have rebooted and even looked in RegEdit to be sure they are there. Has anyone used this API function before with success? And are there any tips I should be aware of?
LOCAL lpszValue,lpcchValue,lpdwReserved
LOCAL lpdwType,lpbData,lpcbData
LOCAL nErrCode
LOCAL nKeyEntry


nKeyEntry = 0

DIMENSION tValue(1,3)
DO WHILE .T.
	nKeyEntry = m.nKeyEntry + 1

	*05/22/2007 08:30:33- GLR -------------------------
	* key Value
	*--------------------------------------------------
	STORE 0 TO lpdwReserved,lpdwType,nErrCode
	STORE SPACE(256) TO lpbData, lpszValue
	STORE LEN(lpbData) TO m.lpcchValue
	STORE LEN(lpszValue) TO m.lpcbData

	nErrCode = RegOpenKey(&hKey,cKey,@nCurrentKey)
	*-- if does not exist, and value provide, create
	IF nErrCode==0
		nErrCode=RegEnumValue(nCurrentKey,;
			M.nKeyEntry,;
			@lpszValue,;
			@lpcchValue,;
			M.lpdwReserved,;
			@lpdwType,;
			@lpbData,;
			@lpcbData;
			)

		DO CASE
			CASE m.nErrCode = ERROR_EOF
				EXIT
			CASE m.nErrCode # ERROR_SUCCESS
				EXIT
		ENDCASE
		=RegCloseKey(nCurrentKey)
	ELSE
		EXIT
	ENDIF
	* Set array values
	DIMENSION tValue(m.nKeyEntry ,3)
	tValue(m.nKeyEntry,1) = LEFT(m.lpszValue,m.lpcchValue)
	*!*	Const REG_SZ = 1
	*!*	Const REG_EXPAND_SZ = 2
	*!*	Const REG_BINARY = 3
	*!*	Const REG_DWORD = 4
	*!*	Const REG_MULTI_SZ = 7
	DO CASE
		CASE lpdwType = REG_SZ
			tValue(m.nKeyEntry,2) = LEFT(m.lpbData,m.lpcbData-1)
		CASE lpdwType = REG_EXPAND_SZ && AND !THIS.lDisAllowExpanded
			tValue(m.nKeyEntry,2) = LEFT(m.lpbData,m.lpcbData-1)
		CASE lpdwType = REG_BINARY
			* Don't support binary
			tValue(m.nKeyEntry,2) = REG_BINARY_LOC
		CASE lpdwType = REG_DWORD
			* You will need to use ASC() to check values here.
			tValue(m.nKeyEntry,2) = LEFT(m.lpbData,m.lpcbData-1)
		OTHERWISE
			tValue(m.nKeyEntry,2) = REG_UNKNOWN_LOC
	ENDCASE

	*-- type
	tValue(m.nKeyEntry,3) = lpdwType

ENDDO
IF m.nErrCode = ERROR_EOF AND m.nKeyEntry # 0
	m.nErrCode = ERROR_SUCCESS
ENDIF
RETURN m.nErrCode
Thanks
Greg Reichert
Next
Reply
Map
View

Click here to load this message in the networking platform