> In any key (in registry), always have a string named "(default)"
> Please help me to read and set new value to this string.
> Thanks
Are you only interested with the ones that say (default)? I think it only means there are no subkeys for that main key and all values are at its default. Maybe seeing that no subkeys exist is sufficient to assume it is (default).
To read and write to registry you can use registry.prg and registry class supplied with VFP. Check samples in solution.app.
ie: Read a single value:
#Define HKEY_CURRENT_USER -2147483647
Local loReg As Registry
Local lcKey, lcKeyVal
loReg = Newobject('Registry', Home()+'FFC\Registry.VCX')
lcKey = 'Software\Microsoft\VisualFoxPro\9.0\Options'
lcKeyVal = '_GENMENU'
cOptVal = ''
If loReg.GetRegKey(m.lcKeyVal,@cOptVal,m.lcKey,HKEY_CURRENT_USER) = 0
? m.cOptVal
endif
Read all entries for a key (or 2 if it is (default) ):
#Define HKEY_CURRENT_USER -2147483647
Local loReg As Registry OF Home()+'FFC\Registry.VCX'
Local lcKey, lnResult
loReg = Newobject('Registry', Home()+'FFC\Registry.VCX')
lcKey = 'Software\Microsoft\VisualFoxPro\9.0\Options'
LOCAL ARRAY aOptions[1]
lnResult = loReg.Enumoptions(@aOptions, m.lcKey, HKEY_CURRENT_USER)
IF m.lnResult = 2 && default
ENDIF
IF m.lnResult = 0
CREATE CURSOR myRegValues (option c(50), value c(200))
APPEND FROM ARRAY aOptions
BROWSE
endif
Cetin Basoz