Declare Function WriteProfileString Lib "kernel32.dll" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Platforms: Win 32s, Win 95/98, Win NT
WriteProfileString sets a value inside of the WIN.INI file. This function can also be used to set numerical values if they are in string form, for example using "1" to represent the number 1. If the section or value does not exist, it will be created. Note that, since Windows normally handles the WIN.INI file by iself, extreme care should be taken when writing directly to it. This function if basically a watered-down version of WritePrivateProfileString because, unlike this function, it works with any INI file. The function returns 0 if an error occurs, or a non-zero value if successful. Note that INI file support is only provided in Windows for backwards compatibility; using the registry to store information is preferred.
Example:
' Set the "Wallpaper" setting in the [Desktop] section of WIN.INI
' to C:\Windows\Clouds.bmp.
' WARNING: Use extreme caution when editing the WIN.INI file, because writing bad data to
' it could have unpredictable and disasterous results to the system!
Dim retval As Long ' return value
' Set the value.
retval = WriteProfileString("Desktop", "Wallpaper", "C:\Windows\Clouds.bmp")
See Also: GetProfileString, WritePrivateProfileString
Category: INI Files
Go back to the alphabetical Function listing.
Go back to the Reference section index.
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/w/writeprofilestring.html