Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Starting an external application in VFP using WinExec
How to retrieve configuration data for a specified printer stored in the registry (PrinterDriverData key)
How to ping a remote site using ICMP API calls
Simple printer queue monitor: deletes, pauses, resumes print jobs for local printer
Confining Windows calculator inside the VFP main window
Storing screen shot of a form to enhanced metafile (*.emf)
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
How to adjust monitor brightness (Vista, monitor with DDC support)
Storing screen shot of a form to bitmap file
How to prevent users from accessing the Windows Desktop and from switching to other applications
How to create non-blocking Winsock server
How to suspend or hibernate your system
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
How to display a user-defined icon in the MessageBox dialog
How to enumerate, add and delete shares on the local computer (WinNT/XP)
How to make application automatically close all documents it opened
How to put a vertical text scrolling on the form (a movie cast)
Testing serial ports
How to make a VFP form fading out when released (GDI+ version)
Sending email messages with Simple MAPI
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Downloading files from the FTP server using InternetReadFile
Changing system colors
Enumerating ODBC Data Sources available on the local computer
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: 106  
    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 (107.20.129.212)
    1.19 hrs.Function: 'GdipResetWorldTransform'
     Function: 'GetMenu'
    2.23 hrs.Function: 'GdipSetTextRenderingHint'
     Example: 'Testing Transparent Menu Class with top-level form (requires VFP9)'
    4.38 hrs.Example: 'Reading the structure of VFP main menu'
    4.39 hrs.Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
    5.89 hrs.Example: 'Retrieving file information for the VFP executable running'
     Example: 'How to print FoxPro form'
    6.34 hrs.Pwd
     Example: 'Pocket PC: modifying keys in the System Registry'
    Google
    Advertise here!