Welcome to MSDN Blogs Sign in | Join | Help

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

Published Thursday, May 05, 2005 2:57 PM by Calvin_Hsia
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Put your registry into a table

Thursday, May 05, 2005 8:30 PM by Alejandro Sosa
Calvin,

Haven't used it yet, but there is gold in this code.

I suggest you add more comments to VFP code in your blog for those that may be new to VFP. Few of those here I am sure, but who knows.

Thank you for a great product.

# WMI part 2 - The WMI Registry Provider

Friday, May 05, 2006 12:10 PM by fox weblog
IntroductionIf you haven't heard of WMI, you might want to skim my previous article on the subject (it's...

# foxpro.catalyst ?? » Blog Archive » FoxLinks.20050509

Sunday, October 14, 2007 1:32 PM by foxpro.catalyst ?? » Blog Archive » FoxLinks.20050509

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker