Using Win32 functions in Visual FoxPro Image Gallery
Registry
..msdn
GetPrivateProfileSectionNames
GetPrivateProfileString
GetProfileString
RegCloseKey
RegCreateKeyEx
RegDeleteKey
RegDeleteValue
RegEnumKey
RegEnumKeyEx
RegEnumValue
RegOpenKeyEx
RegQueryInfoKey
RegQueryValueEx
RegSaveKey
RegSetValueEx
SHEnumKeyEx
SHRegCloseUSKey
SHRegEnumUSKey
SHRegOpenUSKey
WritePrivateProfileSection
WritePrivateProfileString
Code examples:
Writing to INI file
Writing to INI file

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
See also:
  • Reading from INI file
  • Reading entries from Event logs
  • Writing entries to custom Event Log

  •  
    DO declare
     
    LOCAL lcFilename
    lcFilename = "c:\Temp\test.ini"
    = CreateFile(lcFilename)
     
    *** Technique 1
    * adding empty sections
    = WritePrivateProfileSection("General",   "", lcFilename)
    = WritePrivateProfileSection("Language",  "", lcFilename)
    = WritePrivateProfileSection("Devices",   "", lcFilename)
    = WritePrivateProfileSection("Uninstall", "", lcFilename)
    = WritePrivateProfileSection("Old Brown Shoe", "", lcFilename)
     
    *** Technique 2
    * adding key names and associated values to existing sections
     
    = WritePrivateProfileSection("General",;
        "startdir=C:\"     + Chr(0) +;
        "resolution=high"  + Chr(0) +;
        "delay=500"        + Chr(0) +;
        "security=default" + Chr(0),;
        lcFilename)
     
    = WritePrivateProfileSection("Language",;
        "Active=English" + Chr(0),;
        lcFilename)
     
    = WritePrivateProfileSection("Devices",;
        "Default=Fork"   + Chr(0) +;
        "Active=Spoon"   + Chr(0) +;
        "Emergency=Hand" + Chr(0),;
        lcFilename)
     
    *** Technique 3
    * adding new section and a key in one step
    = WritePrivateProfileSection("Environment",;
        "Active=Testing" + Chr(0),;
        lcFilename)
     
    *** Technique 4
    * adding new key to a section which exists
    = WritePrivateProfileString("General",;
        "datapath", "C:\App\Data", lcFilename)
     
    *** Technique 5
    * replacing existing key
    = WritePrivateProfileString("General",;
        "startdir", "C:\App", lcFilename)
     
    *** Technique 6
    * adding new key to the section, which does not exist
    = WritePrivateProfileString("Very Important Section",;
        "Urgent action", "Do not care", lcFilename)
     
    PROCEDURE CreateFile(lcFilename)
        IF FILE(lcFilename)
            DELETE FILE (lcFilename)
        ENDIF
     
        hFile = FCREATE(lcFilename)
        = FCLOSE(hFile)
     
    PROCEDURE declare
        DECLARE WritePrivateProfileSection IN kernel32;
            STRING lpAppName, STRING lpString,;
            STRING lpFileName
     
        DECLARE WritePrivateProfileString IN kernel32;
            STRING lpAppName, STRING lpKeyName,;
            STRING lpString, STRING lpFileName
     

    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    1945 bytes  
    Created: 2001-09-04 12:00:00  
    Modified: 2011-09-16 19:01:14  
    Visits in 7 days: 114  
    Listed functions:
    WritePrivateProfileSection
    WritePrivateProfileString
    Printer friendly API declarations
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (23.22.252.150)
    10.04 hrs.Example: 'How to make a VFP form fading out when released (GDI version)'
    12.25 hrs.Example: 'Obtaining information about all user accounts on a server (WinNT only)'
     Function: 'GdipNewInstalledFontCollection'
    22.06 hrs.Function: 'WNetGetUser'
    22.07 hrs.Example: 'Simple Window Viewer'
    22.18 hrs.Function: 'GdipDrawLineI'
    Function group: 'GDI+ Graphics'
    22.19 hrs.Example: 'Displaying system dialog that selects a folder'
    23.71 hrs.Example: 'Finding parameters for the region specified'
    23.72 hrs.Example: 'Splash Screen for the VFP application'
    1 day(s)Example: 'Enumerating the subkeys of a user-specific key'
    Google
    Advertise here!