I.T. Discussion Community!
-Collapse +Expand
Search Paradox Group:

-Collapse +Expand Paradox To/From
-Collapse +Expand Paradox Store

Prestwood eMagazine

September Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...ObjectPAL Co...OPAL: Langua...   Print This     
  From the September 2013 Issue of Prestwood eMag
Paradox OPAL: Language Details:
Using The Windows Registry with Paradox
Posted 13 years ago on 12/29/2007 and updated 6/12/2008
Take Away: ObjectPAL methods for using the Window's registry to store and retrieve configuration settings.


Two popular techniques for storing configuration information is to use initialization (.INI) files and the Windows registry. Both the older INI files and the newer registry are still used today but Microsoft recommends using the registry over INI files. The registry holds information about the computer hardware configuration, installed software, settings, preferences, and file associations. Should I still use .INI files in 32-bit Windows? You bet. However, use them sparingly. Your first choice for information about your software should be the registry and only when you run into a reason not to use the registry should you use initialization files.

Registry Methods

The preferred method of storing software information is to use the registry. ObjectPAL offers several methods for manipulating the registry including setRegistryValue(), getRegistryValue(), deleteRegistryValue(), searchRegistry(), and enumRegistryKeys().

Using setRegistryValue() and getRegistryValue()

The setRegistryValue() method sets a value in the registry. Here is the syntax:

setRegistryValue ( const key String, const value String, const data AnyType, const rootKey LongInt) Logical

If either the key or value do not exist, it will be created.

The rootKey is analogous to a directory drive. The rootKey should be set with the predefined constants: regKeyCurrentUser, regKeyClassesRoot, regKeyLocalMachine, or regKeyUser.

The following example sets the current ObjectPAL level in the registry.

;Button :: pushButton 
method pushButton(var eventInfo Event) 
	sKey, sValue, sData, sLevel String 
sKey = "Software\\Borland\\Paradox\\7.0\\PDOXWIN\\Properties" 
sValue = "Level" 
sData = "Advanced" 
setRegistryValue( sKey, sValue, sData, regKeyCurrentUser ) 

getRegistryValue() is the counter part to setRegistryValue(). It retrieves a value from the registry. Here is the syntax:

getRegistryValue ( const key String, const value String , const rootKey LongInt ) AnyType

The following example get the current ObjectPAL level from the registry.

;Button :: pushButton
method pushButton(var eventInfo Event)
	sLevel, sKey, sValue String 
sKey = "Software\\Borland\\Paradox\\7.0\\PDOXWIN\\Properties"
sValue = "Level"
sLevel = getRegistryValue(sKey, sValue, regKeyCurrentUser )
sLevel.view("ObjectPAL Level")

Notice that the syntax for getRegistryValue() shows that it returns a value of type AnyType, sLevel is of type string because we knew ahead of time what the return type would be. If you don't, then return the value to a variable of type AnyType. Setting and retrieving values from the Windows registry is easy with Paradox.


Share a thought or comment...
Comment 1 of 1
<p>a real gem of information - it didn&amp;#39;t even occur to me that&amp;nbsp;OPAL had ready access tothe registry.</p><p>thanks for the article Mike</p>
Posted 12 years ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1304A1
Enter key:
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100770 Counter
Since 4/2/2008

Follow PrestwoodBoards on: 

©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech