SetProfileString

Sets the value of a profile entry in an initialization file. This function returns an empty string if the operation succeeds or an error message if the operation fails.

See also GetProfileString.

Syntax

SetProfileString(IniPath, Section, Entry, Value)
IniPath

Fully qualified path (drive, directory, filename, and extension) of the initialization file.

Section

The section of the initialization file in which the entry is to be set.

Entry

The name of the entry that is to be set.

Value

The value to which to set the entry.

Example

<!---This example uses SetProfileString to set the 
     timeout value in an initialization file. --->

<HTML>
<HEAD>
<TITLE>SetProfileString Example</TITLE>
</HEAD>

<BODY  bgcolor="#FFFFD5">

<H3>SetProfileString Example</H3>

This example uses SetProfileString to set the value of timeout in an 
initialization file. Enter the full path of your initialization file, 
specify the timeout value, and submit the form.

<!---  This section of code checks to see if the form was submitted.
       If the form was submitted, this section sets the initialization
       path and timeout value to the path and timeout value specified 
       in the form                                                        --->
<CFIF Isdefined("Form.Submit")>

    <CFSET IniPath=FORM.iniPath>
    <CFSET Section="boot loader">
    <CFSET MyTimeout=FORM.MyTimeout>
    <CFSET timeout=GetProfileString(IniPath, Section, "timeout")>

    <CFIF timeout Is Not MyTimeout>
        <CFIF MyTimeout Greater Than 0>
            <HR size="2" color="#0000A0">
            <P>Setting the timeout value to <CFOUTPUT>#MyTimeout#</
CFOUTPUT></P>
            <CFSET code=SetProfileString(IniPath, Section, "timeout", 
MyTimeout)>
            <P>Value returned from SetProfileString: <CFOUTPUT>#code#</
CFOUTPUT></P>
        <CFELSE>
            <HR size="2"  color="red">
            <P>Timeout value should be greater than zero in order to 
provide time for user response.</P>
            <HR size="2"  color="red">    
        </CFIF>
    <CFELSE>
        <P>The timeout value in your initialization file is already 
<CFOUTPUT>#MyTimeout#</CFOUTPUT>.</P>    
    </CFIF>

    <CFSET timeout=GetProfileString(IniPath, Section, "timeout")>
    <CFSET default= GetProfileString(IniPath, Section, "default")>
    
    <H4>Boot Loader</H4>
    <P>Timeout is set to: <CFOUTPUT>#timeout#</CFOUTPUT>.</P>
    <P>Default directory is: <CFOUTPUT>#default#</CFOUTPUT>.</P>
            
</CFIF>

<FORM ACTION="setprofilestring.cfm" METHOD="POST">
<HR size="2" color="#0000A0">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
    <td>Full Path of Init File</td>
    <td><INPUT type="Text" name="IniPath" value="C:\myboot.ini"></td>
</tr>
<tr>
    <td>Timeout</td>
    <td><INPUT type="Text" name="MyTimeout" value="30"></td>
</tr>
<tr>
    <td><INPUT type="Submit" name="Submit" value="Submit"></td>
    <td></td>
</tr>
</table>

</FORM>
<HR size="2" color="#0000A0">
</BODY>
</HTML>