Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: le tan duc
  Where is le tan duc?
 Phu eyn
 Vietnam
 le tan duc
 Tags
Subject: RE: read or setvalue for a string
Thread ID: 143735 Message ID: 143745 # Views: 20 # Ratings: 0
Version: Visual FoxPro 8 Category: General VFP Topics
Date: Friday, August 31, 2007 11:39:27 AM         
   


> 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




COMPLETE THREAD

Tip: click here to scan for Windows Registry Errors and Optimize PC performance
read or setvalue for a string Posted by le tan duc @ 8/31/2007 10:51:36 AM
RE: read or setvalue for a string Posted by Vladimir Zhuravlev @ 8/31/2007 11:36:39 AM
RE: read or setvalue for a string Posted by Cetin Basoz @ 8/31/2007 11:39:27 AM