View comments | RSS feed

GetProfileString

Description

Gets an initialization file entry.

An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initialization file has the suffix INI; for example, boot.ini, Win32.ini.

Returns

An entry in an initialization file, as a string. If there is no value, returns an empty string.

Category

System functions

Function syntax

GetProfileString(iniPath, section, entry)

See also

GetProfileSections, GetProfileString, SetProfileString

Parameters

Parameter Description

iniPath

Absolute path (drive, directory, filename, extension) of initialization file; for example, C:\boot.ini

section

Section of initialization file from which to extract information

entry

Name of value to get

Example

<h3>GetProfileString Example</h3>
Uses GetProfileString to get the value of timeout in an initialization file. Enter
the full path of your initialization file, and submit the form. <!--- If the form was submitted, it gets the initialization path and timeout value specified in the form ---> <cfif Isdefined("Form.Submit")> <cfset IniPath = FORM.iniPath> <cfset Section = "boot loader"> <cfset timeout = GetProfileString(IniPath, Section, "timeout")> <h4>Boot Loader</h4> <!--- If no entry in an initialization file, nothing displays ---> <p>Timeout is set to: <cfoutput>#timeout#</cfoutput>.</p> </cfif> <form action = "getprofilestring.cfm"> <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><input type = "Submit" name = "Submit" value = "Submit"></td> <td></td> </tr></table> </form>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


basildon bond said on Jan 13, 2006 at 9:43 AM :
Shouldn't the form tag in the example code have a method="post" attribute?
TParker said on Jul 15, 2008 at 2:30 PM :
What this doesn't say... is that if the .INI file isn't there, a 'warning' entry for an 'InvalidIniPathException' exception will be appended to your 'cfusion-out.log' (for CF7) or the CF server's 'application.log' (for CF8)...

... and an 'InvalidIniSectionNameException' warning will get logged for a missing section.

To avoid the stray log entries, use FileExists() to verify that the INI file is there, and GetProfileSections() to make sure the desired section exists...

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000492.htm