Share via


Read and Write Visual FoxPro Registry Values Sample

File: ...\Samples\Solution\WINAPI\Regfox.scx

This sample shows how to access the Windows Registry using the native Visual FoxPro DECLARE-DLL command. The Windows API provides a number of functions you can use to access, read and write to the registry. The Registry.prg class library in ...\Samples\Classes contains a class definition that exposes these functions as methods that you can call in your applications.

The contents of the Visual FoxPro Options dialog, Field Mapping settings, and Label definitions (to name a few) are stored in the Registry. Since many of these settings are not available using SET functions, you can use Registry functions to access these values. The following code populates an array of all the settings in the Options dialog:

regfile = HOME(2)+"classes\registry.prg"
SET PROCEDURE TO (m.regfile) ADDITIVE
oReg = CreateObject("FoxReg")

DIMENSION aFoxOptions[1,2]
m.nErrNum = oReg.EnumFoxOptions(@aFoxOptions) 

The following code calls the SetFoxOption method of the FoxReg class (defined in Registry.prg) to set TALK OFF in the registry:

regfile = HOME(2)+"classes\registry.prg"
SET PROCEDURE TO (m.regfile) ADDITIVE
oReg = CreateObject("FoxReg")

m.nErrNum = oReg.SetFoxOption("TALK","OFF")

See Also

Tasks

Get Application Information from the Windows Registry Sample

Solution Samples

Reference

Registry Access Foundation Class

Application Registry Foundation Class

Visual FoxPro Foundation Classes A-Z

Other Resources

Windows API Solution Samples