Put your registry into a table

It’s pretty easy to use Foxpro to examine the registry. Here’s some simple recursive code I whipped up to put registry keys into a table.

#define HKCU BITSET(0,31)+1

CLEAR

LOCAL oreg as "registry" OF HOME()+"samples\classes\registry.prg"

*cPath="Software\Microsoft\VisualFoxPro\9.0"

cPath="Software\Microsoft\Windows"

CREATE CURSOR reg (level i,key c(40),name c(40),value c(100))

SET ALTERNATE TO t

SET ALTERNATE on

enumreg(cPath,HKCU,0)

LOCATE

BROWSE LAST

SET ALTERNATE to

MODIFY COMMAND t.txt nowa

PROCEDURE enumreg(cPath as String,nhive as Integer,nLevel as Integer)

      LOCAL i,oreg,aVals[1,1],aKeys[1]

      oreg=NEWOBJECT("registry",HOME()+"samples\classes\registry.prg")

      oreg.openkey(cPath,nhive)

      IF oreg.EnumKeyValues(@aVals)=0

            FOR i = 1 TO MIN(ALEN(aVals,1),100)

                  ?REPLICATE(" ",nLevel),nLevel,cPath,aVals[i,1],"=",aVals[i,2]

                  INSERT INTO reg VALUES (nLevel,REPLICATE(" ",nLevel),aVals[i,1],aVals[i,2])

            ENDFOR

      ENDIF

      IF oreg.EnumKeys(@aKeys)=0

            FOR i = 1 TO ALEN(aKeys,1)

                  ?REPLICATE(" ",nLevel),nLevel,cPath+aKeys[i]

                  INSERT INTO reg VALUES (nLevel,REPLICATE(" ",nLevel)+aKeys[i],"","")

                  enumreg(cPath+"\"+aKeys[i],nHive,nLevel+1)

            ENDFOR

      ENDIF

      RETURN

59031