Microsoft KB Archive/190878

= How To Get Visual FoxPro Options Registry Settings =

Article ID: 190878

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q190878



SUMMARY
The Microsoft Knowledge Base article 130578, "How to Customize the Visual FoxPro Environment" describes how to echo the Visual FoxPro environment settings by opening the Options dialog box from the Tools menu, holding the SHIFT key and clicking OK. However, this method does not show all of the Options settings, such as the setting for Asynchronous execution under the Remote Data tab. This article shows how to get all of the settings for Visual FoxPro that are listed in the registry.



MORE INFORMATION
 In order for values to display, you must first save the settings to the registry. This task can be accomplished by selecting Options from the Tools menu. Click the Set as Default button, and then click OK to close the dialog box.  Save the following code and run it with the syntax DO WITH . For example, if the program file were saved to Readsettings.prg, run the program by typing the following in the Command window to save the settings to a text file called MySettings.Txt: DO READSETTINGS.PRG WITH "MySettings.Txt". After the program runs, it displays an edit window that shows the current settings: *-- Code begins here. PARAMETER lsOutput

*-- Defines from Winreg.h

#define KEY_QUERY_VALUE     0x0001 #define HKEY_CURRENT_USER   0x80000001

lnKeyHandle = 0 liValue = 0 lpszValue = SPACE(255) lpcchValue = 255 lpdwType = SPACE(255) lpbData=SPACE(255) lpcbData=255

DECLARE RegOpenKeyEx IN WIN32API INTEGER, STRING, INTEGER, ; INTEGER, INTEGER @nKeyHandle

DECLARE RegEnumValue IN WIN32API INTEGER lnKeyHandle, INTEGER ; liValue; STRING @lpszValue, INTEGER @lpcchValue, INTEGER, STRING @lpdwType, ; STRING @lpbData, INTEGER @lpcbData

*-- Get a handle for the Visual FoxPro Options key. lnResult=RegOpenKeyEx(      HKEY_CURRENT_USER, "Software\Microsoft\VisualFoxPro\6.0\Options", ;        0, KEY_QUERY_VALUE, @LnKeyHandle)

*-- Get a file handle for output file. IF FILE(lsOutput) ERASE(lsOutput) ENDIF lhFile = FCREATE(lsOutput) lnReturn = .T.

DO WHILE lnReturn = .T.

*-- Clear the buffers through each loop. lpszValue = SPACE(255) lpcchValue = 255 lpdwType  = SPACE(255) lpbData   = SPACE(255) lpcbData  = 255

*-- Walk through the values for the key. lnReturn=RegEnumValue(lnKeyHandle,liValue,@lpszValue,@lpcchValue,0,;       @lpdwType,@lpbData,@lpcbData)

*-- Quit when we start getting empty strings. IF LEN(ALLTRIM(lpbData)) = 0 AND LEN(ALLTRIM(lpszValue)) = 0 lnReturn = .F.          LOOP ENDIF

*-- Strip anything after the first null character. lpszValue = SUBSTR(lpszValue, 1, AT(CHR(0),lpszValue) - 1) lpbData = SUBSTR(lpbData, 1, AT(CHR(0),lpbData) - 1)

*-- Write it out to the file. lFresult=FPUTS(lhFile,ALLTRIM(lpszValue) + " " + ALLTRIM(lpbData))

*-- Increment the value index to move to the next value. liValue = liValue + 1 ENDDO

*-- Close our file handle and open an edit window. FCLOSE(lhFile) MODIFY FILE (lsOutput) *-- Code ends here. 

