Sets the value of a profile entry in an initialization file. The function returns an empty string if the operation succeeds, or an error message if the operation fails.
SetProfileString(iniPath, section, entry, value)
<!---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 whether 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>