Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Enumerating data formats currently available on the clipboard
Winsock: sending email messages (SMTP, port 25)
Detecting changes in connections to removable drives (VFP9)
Custom FTP Class for Visual FoxPro application
How to download a file from the FTP server using FtpGetFile
Splash Screen for the VFP application
How to activate Windows Calculator
Mapping and disconnecting network drives
Custom HttpRequest class (WinINet)
How to convert a bitmap file to monochrome format (1 bpp)
Custom HttpRequest class (WinHTTP)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Establishing connection using the SQLDriverConnect
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Using Font and Text functions
Displaying bitmap using the AlphaBlend function
Using WM_COPYDATA for interprocess communication (VFP9)
Using EnumPrinters function to enumerate locally installed printers
Extensible Storage Engine class library
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

  •  
    using System;
    using System.IO;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
     
    namespace ConsoleApplication1
    {
        partial class Program
        {
            static void WriteToIniFile()
            {
                string iniFilename = @"c:\temp\app1.ini";
     
                /* first WritePrivateProfile call 
                 * implicitly creates the target INI file
                 * if required
                 */
     
                //if (!File.Exists(iniFilename))
                //{
                //    FileStream fs = new FileStream(iniFilename,
                //        FileMode.Create, FileAccess.ReadWrite);
                //    fs.Close();
                //}
     
                //writes entire section of INI file
     
                WritePrivateProfileSection("Environment",
                    "Current Directory=" + 
                        Environment.CurrentDirectory + (char)0 +
                    "System Directory=" + 
                        Environment.SystemDirectory + (char)0 +
                    "User Name=" + 
                        Environment.UserName + (char)0 +
                    "Machine Name=" + 
                        Environment.MachineName + (char)0 +
                    "OS Version=" + 
                        Environment.OSVersion + (char)0,
                    iniFilename);
     
                WritePrivateProfileSection("Application",
                    "Company=" + 
                        Application.CompanyName + (char)0 +
                    "Product=" + 
                        Application.ProductName + (char)0 +
                    "Version=" + 
                        Application.ProductVersion + (char)0 +
                    "Startup path=" + 
                        Application.StartupPath + (char)0 +
                    "Culture=" + 
                        Application.CurrentCulture.DisplayName + (char)0,
                    iniFilename);
     
                //writes a string into a specified section of INI file
                WritePrivateProfileString("Event Log", "File Created",
                    DateTime.Now.ToString(), iniFilename);
            }
     
            [DllImport("kernel32.dll",
                CharSet = CharSet.Unicode, SetLastError = true)]
            static extern bool WritePrivateProfileSection(
                string lpAppName, string lpString,
                string lpFileName);
     
            [DllImport("kernel32.dll",
                CharSet = CharSet.Unicode, SetLastError = true)]
            static extern bool WritePrivateProfileString(
                string lpAppName, string lpKeyName,
                string lpString, string lpFileName);
     
        }
    }
     

    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    2531 bytes  
    Created: 2001-09-04 12:00:00  
    Modified: 2011-09-16 19:01:14  
    Visits in 7 days: 130  
    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 (54.235.20.17)
    1.5 hrs.Example: 'Using the ChooseColor function'
    8.32 hrs.Function: 'UrlGetPart'
    Function group: 'Shell Lightweight Utility APIs -- Path Functions'
     Example: 'Pocket PC: base class'
    13.09 hrs.Example: 'Retrieving size of a remote file'
     Example: 'How to make the caption of a VFP application flashing in the Windows task bar'
    18.83 hrs.
    Function group: 'Shell Lightweight Utility APIs -- Path Functions'
    21.19 hrs.Example: 'Using Change Notification Objects to monitor changes to the printer or print server'
     Function: 'WNetEnumResource'
    1 day(s)Function: 'GetForegroundWindow'
     Example: 'Current keyboard type'
    Google
    Advertise here!