Hi,
Where is the documentation for registry reads, writes and otherwise total registry mods? I've been trying to get vfp's ffc registry.vcx to work without success and am finding very little usage documentation. The .h file doesn't help either. So the question is, "Where is good docs with example code" on its usage? Oh, the VFP help file has nothing for functions like IsKey(), or any of the others...
Below is a paste of my Sandbox...
Thanks, Stanley
Where is the documentation for registry reads, writes and otherwise total registry mods? I've been trying to get vfp's ffc registry.vcx to work without success and am finding very little usage documentation. The .h file doesn't help either. So the question is, "Where is good docs with example code" on its usage? Oh, the VFP help file has nothing for functions like IsKey(), or any of the others...
Below is a paste of my Sandbox...
Thanks, Stanley
Code:
#Define HKEY_CLASSES_ROOT -2147483648 && BITSET(0,31)
#Define HKEY_CURRENT_USER -2147483647 && BITSET(0,31)+1
#Define HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2
#Define HKEY_USERS -2147483645 && BITSET(0,31)+3
lcPath = 'Software\MyNewHopefullyUniqueKey\123456\I_HOPE_YOU_NAMED_THIS'
#UnDef _PATH
#Define _PATH (lcPath)
Public oRegistry
SET CLASSLIB TO "d:\licgen\licgen_2015\classes\registry.vcx"
#include REGISTRY.H
oRegistry = Newobject("registry", "registry.vcx")
*oRegistry = Newobject("registry", Home() + "ffc\registry.vcx")
*.CloseKey()
*.DeleteKey
*.DeleteKeyValue
*=GetRegKey('DbcName', @cValue, Path, HKEY_CURRENT_USER)
*?zz
*!* aa= oRegistry.GetKeyValue(Path, HKEY_CURRENT_USER)
*!* ?aa
*!* lcResource=oRegistry.getRegKey('resourceTo', @lcResource, Path', HKEY_CURRENT_USER)
*!* MessageBox("My resourcefile is named: "+lcResource)
*!*
*!*
*!*
*!* bb= oRegistry.GetRegKey(Path, HKEY_CURRENT_USER)
*!* ?bb
*!* cc= oRegistry.IsKey(Path, HKEY_CURRENT_USER)
*!* ?cc
llIsThere=oRegistry.IsKey(_PATH, HKEY_CURRENT_USER)
IF llIsThere
MessageBox("NjSrv020.Kamrat is installed")
ELSE
MessageBox("NjSrv020.Kamrat is not installed")
RETURN
ENDIF
*.OpenKey
*.SetKeyValue
*.SetRegKey
Release oRegistry
return
If oRegistry.OpenKey("Software\MyNew2HopefullyUniqueKey\123456", HKEY_CURRENT_USER, .T.) = 0
*SET STEP on
=oRegistry.CloseKey()
If oRegistry.setregkey("I_HOPE_YOU_NAMED_THIS", ;
"somthis", ;
"Software\MyNew1HopefullyUniqueKey\123456\", ;
HKEY_CURRENT_USER) != 0
Messagebox("Sorry error setting the registry value!", 48)
Return
Endif
Messagebox("Regedit will run while I wait for you to go see your new value" + ;
CHR(13) + "Look under the HKEY_CURRENT_USER hive and click on the Software key..." +;
CHR(13) + "then click on MyNewHopefullyUniqueKey key and look to the right and you should see " +;
"I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS")
Run /N regedit
Messagebox("Are you done looking and want me to delete it?")
*!* If oRegistry.DeleteKeyValue("I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS", ;
*!* "Software\MyNewHopefullyUniqueKey\123456\", ;
*!* HKEY_CURRENT_USER) != 0
*!* Messagebox("Sorry error deleting the registry value I_HOPE_YOU_DONT_HAVE_A_VALUE_NAMED_THIS!",48)
*!* Return
*!* Endif
*!* Messagebox("Now that we've deteleted the value, lets delete the 2 new keys")
*!* If oRegistry.DeleteKey(HKEY_CURRENT_USER,"Software\MyNewHopefullyUniqueKey\123456") != 0
*!* Messagebox("Sorry error deleting the registry key 123456!",48)
*!* Else
*!* If oRegistry.DeleteKey(HKEY_CURRENT_USER,"Software\MyNewHopefullyUniqueKey") != 0
*!* Messagebox("Sorry error deleting the registry key MyNewHopefullyUniqueKey!",48)
*!* Endif
*!* Return
*!* Endif
Else
Messagebox("We weren't able to create and open the new key",48)
Endif
***********************************
Local loregistry, sValue, sPath
sValue = ''
sPath = HOME(1) + 'FFC\registry.vcx'
SET CLASSLIB TO (sPath)
#DEFINE HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2
loregistry = NEWOBJECT('registry')
IF loregistry.OpenKey('Software\Mycompany123\Myproject123', HKEY_LOCAL_MACHINE,.T.) = 0
IF loregistry.GetKeyValue('datapath',@sValue) != 0
sValue =ADDBS(GetShortPath(Alltrim(GETDIR(sValue, 'Locate Myproject123 Data.', 'Browse For Folder'))))
IF loregistry.SetRegKey('datapath', sValue, 'Software\Mycompany123\Myproject123', HKEY_LOCAL_MACHINE) != 0
MESSAGEBOX('datapath was unable to be set!', 16, 'Error...')
RETURN
ENDIF
ENDIF
ENDIF
=loregistry.CloseKey()
IF MESSAGEBOX('Do you wish to delete the registry entries you have just made?',36, 'Delete?') = 6
IF loregistry.DeleteKeyValue('datapath', 'Software\Mycompany123\Myproject123', HKEY_LOCAL_MACHINE) = 0
IF loregistry.DeleteKey(HKEY_LOCAL_MACHINE, 'Software\Mycompany123\Myproject123') = 0
IF loregistry.DeleteKey(HKEY_LOCAL_MACHINE, 'Software\Mycompany123') != 0
MESSAGEBOX('Unable to delete entries!', 16, 'Error...')
ENDIF
ELSE
MESSAGEBOX('Unable to delete entries!', 16, 'Error...')
ENDIF
ELSE
MESSAGEBOX('Unable to delete entries!', 16, 'Error...')
ENDIF
endif
Function GetShortPath
* Turn the path into a dos path
* so that paths still work with macro substitution
Parameters sFileName
Local nRes, sPath
Declare Integer GetShortPathNameA In Win32API As GetShortPathName String, String, Integer
**Create a buffer
sPath = Replicate(Chr(32), 165) + Chr(0)
**retrieve the short pathname
nRes= GetShortPathName(sFileName, @sPath, 164)
Clear Dlls GetShortPathName
**remove all unnecessary chr$(0)'s and send it back
Return (Left(sPath, nRes))
Endfunc