Purpose |
Writes a string in the specified section of a Windows profile (*.ini file)
|
Author | Date of code (original) | Updated on | Date of page (original) | Updated on |
Bill Thoen bthoen@ctmap.com |
09Jan2001
|
09Jan2001
|
09Jan2001
|
09Jan2001
|
Restrictions on use |
This module is distributed under the terms of the Lesser GNU General
Public License. Restrictions on the use of this work in a commercial
application or derivative work is described in the Lesser GNU General
Public License page at:
http://www.fsf.org/copyleft/lesser.html
|
Description |
ProfileWrite stores a string associated with a key name into a
specified section within a private Windows initialization file.
|
External resources |
Windows KERNEL32 DLL
|
Declare statement of sub_function. Include in your program. Copy/Paste if needed. |
sub ProfileWrite ( ByVal sSection as String, 'Section name (in [] brackets) ByVal sKey as String, 'Key variable in section ByVal sValue as string, 'Value to write ByVal sFile as String) 'Profile filename |
Returned value(s) (function only) |
|
Other required declare statement(s). Include in your program. Copy/Paste if needed. |
none |
MapBasic Code. Copy/Paste if needed.
|
include "Profile.def" Declare Function WritePrivateProfileString32 Lib KERNEL32 alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Smallint sub ProfileWrite ( ByVal sSection as String, ByVal sKey as String, ByVal sValue as string, ByVal sFile as String) sValue = """" + sValue + """" if not WritePrivateProfileString32 ( sSection, sKey, sValue, sFile) then Note "Error writing " + sKey + " into " + sFile end if end sub |
Availability for download |
Profile.zip |
Example |
include "Profile.def" '... dim sProfile as string sProfile = ApplicationDirectory$()+"Example.ini" call ProfileWrite ("Main", "DefaultColor", "Red", sProfile) 'Example.ini now contains (at least): '[Main] 'DefaultColor="Red" |
Comments |
|
See also |
ProfileRead( ) |