VDF-GUIdance logo



  Visual DataFlex Logo
  

Shared knowledge leads to accumulated knowledge

        Printer Friendly Page


Size: 2 KB Download
Date Created: 07/14/2004
Date Updated: 07/14/2004
Author: Allan Kim Eriksen
Company: NordTeam Gruppen ApS
Summary:
This package contains global procedure and global functions to gain access to the windows registry database

Global registry access


by Allan Kim Eriksen

This package contains global methods to easily access the windows registry.
These global methods consist of three functions and one procedure.
The methods are in fact wrapper functions to a subclass of the cRegistry class which does provide the functionality.

Functions:
ReadGlobalReg Global Handle hRoot String sRegkey String sValue String sStandard Returns String
WriteGlobalReg  Global Handle hRoot String sRegkey String sValue String sTxt
DoesGlobalKeyExists Global Handle hRoot String sRegKey Returns Boolean

Procedure:
DeleteGlobalReg Global Handle hRoot String sRegKey String sValue

For hRoot you can use any of the following root keys:
HKEY_CLASSES_ROOT 
HKEY_CURRENT_USER 
HKEY_LOCAL_MACHINE 
HKEY_USERS
HKEY_PERFORMANCE_DATA
HKEY_CURRENT_CONFIG  
HKEY_DYN_DATA

Example



The following example will list all of the VDF versions installed on this machine.
Since the code requires VDF8 or higher we are starting to count from that version to make our lives a little bit easier.


Define CS_DAWVDF For  "SOFTWARE\Data Access Worldwide\Visual DataFlex\"
Define CS_VDFVER For  "CurrentVersion"

Use GlobalReg.pkg //

Procedure ShowInstalledVDFVersions
  String sVersion
  Integer iLoop
  Integer iMajor
  Integer iMinor
  Integer iStart
  
  Showln " :: This program has found the following versions of Visual DataFlex installed "
  Showln " :: on this system:"

  Move 80 To iLoop  // We're starting from VDF8 to simplify the example
  
  While (iLoop<200) // Stop at VDF19.9
    Move (mod(iLoop,10)) To iMinor
    Move (iLoop/10) To iMajor
    Get ReadGlobalReg HKEY_LOCAL_MACHINE (CS_DAWVDF+"\"+string(iMajor)+"."+string(iMinor)) CS_VDFVER "" To sVersion
    If (sVersion<>"") Begin
      Showln sVersion
    End
    Increment iLoop
  Loop
End_Procedure // ShowInstalledVDFVersions

This example will only show installed versions of VDF because the default value is returned to sVersion if the registry value is not found. The default value that we pass is "" (an empty string).

Download



Globalreg.zip ~ 2Kb