Accessing INI File Keys

The following methods allow you to read and write key values in .INI files.

getINISetting <filename_string> <section_string> <key_string>

Reads an INI setting from the specified file. Within the file, the section identified by <section_string> is located, and then the key specified by the <key_string> is located. The value assigned to this key is then returned as a string. If the specified file, section, or key is not found, a null string is returned.

For example:

GetINISetting "c:/3dsmax6/3dsmax.ini" "Directories" "Scenes"

If the specified file, section, or key is not found, a null string is returned.

In 3ds Max 6 and higher,

If only the .ini file is specified, the method will return an array of the sections in the .ini file. If only the .ini file and section are specified, the method will return an array of the keys in the section.

 

setINISetting <filename_string> <section_string> <key_string> <key_value_string>

Sets an INI setting in the specified file. Returns a value of true if the key value was written to the file, false if the key was not written. Within the file, the section identified by <section_string> is located, and then the key specified by the <key_string> is located. The <key_value_string> is then assigned to this key.

For example:

setINISetting "c:/3dsmax6/3dsmax.ini" "Directories" "Scenes" "c:/3dsmax/scenes"

If the specified file, section, or key is not found, a new file, section, or key is created.

If the specified file is read-only, or the file is open in MAXScript, the key value is not written to the file.

The method returns true when writing has been successful, false when writing has failed.

 

delIniSetting <filename_string> <section_string> <key_string>

Deletes the specified key from the supplied section of the given INI file.

 

delIniSetting <filename_string> <section_string>

Deletes the section and all keys in the section of the given INI file.

Related Methods:

getMAXIniFile()

Returns the current 3dsmax.ini file as a string. For some products that store the ini settings in the registry, this method returns undefined.

See also

External File Methods