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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading registry in VFP 1

Jureczek13

Programmer
Apr 19, 2023
8
CA
Under HKEY_LOCAL_MACHINE\SOFTWARE\Native Instruments\ I have many keys, each represents name of library (for example: "Symphobia 2", "Electric Keys", "Guitar Swell", etc.)
I need to get a list of all those keys, and for each key get a value of a sub-key "ContentDir".

1746494082382.png
 
Are you familiar with the Stonefield Database Toolkit (stonefield.com). I'm thinking Doug Hennig, the creator of that, has something to read the registry in there. It's open source now so it may be best to find it on GitHub. Also, Rick Strahl might have something in his tools at www.west-wind.com.
 
Jureczek13,

This goes untested, since I don't have that software on my machine:

Code:
#DEFINE HKEY_LOCAL_MACHINE    0x80000002
#DEFINE INSTRUMENTS            "SOFTWARE\Native Instruments"

SET CLASSLIB TO (HOME(1) + "FFC\registry") ADDITIVE

LOCAL Reg AS registry

m.Reg = CREATEOBJECT("registry")

LOCAL ARRAY Entries[1]
LOCAL NativeInstruments AS Integer

m.Reg.OpenKey(INSTRUMENTS, HKEY_LOCAL_MACHINE, .F.)
m.Reg.EnumKeys(@m.Entries)
m.Reg.CloseKey()

LOCAL Instrument AS String
LOCAL kValue AS String

CREATE CURSOR curInstruments (Instrument Varchar(254), ContentDir Varchar(254))

IF VARTYPE(m.Entries[1]) != "L"

    FOR EACH m.Instrument IN m.Entries

        m.Reg.OpenKey(INSTRUMENTS + "\" + m.Instrument, HKEY_LOCAL_MACHINE, .F.)

        IF m.Reg.GetKeyValue("ContentDir", @m.kValue) == 0

            INSERT INTO curInstruments VALUES (m.Instrument, m.kValue)

        ENDIF

        m.Reg.CloseKey()

    ENDFOR

ENDIF

BROWSE
 
You don't need Stonefield Databse Toolkit to do this, as atlopes sample already proves.

But just open the help, search registry and you're pointed to a Registry Access Foundation Class:
1746512789531.png
Foundation classes (aka FoxPro Foundation Classes - FFC) are a set of libraries that come with VFP and you'll also find this in earlier VFP versions, I guess since 6, maybe even earlier, too.
The help topic describes this registry library, what it offers and how it's used.
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top