Chinaunix首页 | 论坛 | 博客
  • 博客访问: 571886
  • 博文数量: 208
  • 博客积分: 3286
  • 博客等级: 中校
  • 技术积分: 1780
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-24 20:38
文章分类

全部博文(208)

文章存档

2012年(7)

2011年(28)

2010年(21)

2009年(76)

2008年(65)

2007年(11)

我的朋友

分类:

2009-03-27 16:22:41

AddProfString

InstallShield 2009 » InstallScript Language Reference

The AddProfString function unconditionally adds a profile string to an .ini file. Use AddProfString only to add non-unique keys, such as those found in the [386Enh] section of the System.ini file (device = ...). AddProfString adds the line KEY=VALUE to the end of the specified .ini file section. It does not replace or update an existing key. To update an existing non-unique key, call . To add a unique key or to update an existing unique key's value in an .ini file, call .

Syntax

AddProfString ( szFileName, szSectionName, szKeyName, szValue );

Parameters

AddProfString Parameters 

Parameter

Description

szFileName

Specifies the name of the .ini file to which the profile string is to be added. If szFileName is unqualified (that is, if a drive designation and path are not included), InstallShield searches for the file in the Windows folder. If the file does not exist, it is created in the specified folder; if a path is not included in file name, the file is created in the Windows folder. If the file name is qualified with a path that does not exist, AddProfString fails.

szSectionName

Specifies the name of a section in the .ini file section. The profile string is inserted at the end of that section. If the section does not exist, InstallShield creates it. The section name should not be enclosed within delimiting brackets ( [ ] ). Note that the profile string is inserted even if the key specified by szKeyName already exists in that section.

szKeyName

Specifies the name of the key to insert. The value of this parameter will appear to the left of the equal sign in the profile string (szKeyName = szValue).

szValue

Specifies the value to assign to the key. The value of this parameter will appear to the right of the equal sign in the profile string (szKeyName = szValue).

Return Values

AddProfString Return Values 

Return Value

Description

0

AddProfString successfully added the specified profile string to the .ini file.

< 0

AddProfString was unable to add the profile string.

Additional Information

  • AddProfString does not use the Windows API to change the .ini files. The Windows API cannot handle the types of changes possible with AddProfString.
  • Changes made to .ini files can be logged for uninstallation. However, there are some important restrictions to be aware of. For more information, see .

See Also

PreviousNext
Help Library


AddProfString Example

InstallShield 2009 » InstallScript Language Reference

Note

To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*-----------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the functions AddProfString and GetProfString.

*

* This script adds a profile string to a file;  then it

* retrieves and displays the string that was added.

*

* Note: The first time you run this script, it will create a

*       file named ISExampl.ini in the root of drive C.  You

*       can delete that file when you have finished analyzing

*       this script.

*

\*-----------------------------------------------------------*/

#define EXAMPLE_INI "C:\\ISExampl.ini"

// The new section, key, and value to add to the file.

#define NEW_SECTION "New Section"

#define NEW_KEY     "New Key"

#define NEW_VALUE   "Test"

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

export prototype ExFn_AddProfString(HWND);

function ExFn_AddProfString(hMSI)

    STRING svResult;

begin

    // Add the profile string to the file.

    if (AddProfString (EXAMPLE_INI, NEW_SECTION, NEW_KEY, NEW_VALUE) != 0) then

        // Display an error message if the string could not be added.

        MessageBox ("AddProfString failed.", SEVERE);

    else

        // Retrieve the value of a key from the file.

        if (GetProfString (EXAMPLE_INI, NEW_SECTION, NEW_KEY, svResult) != 0) then

            // Display an error message if the string could not be retrieved.

            MessageBox ("GetProfString failed.", SEVERE);

        else

            // Display the key and its current value.

            MessageBox (NEW_KEY + "=" + svResult, INFORMATION);

        endif;

    endif;

end;

阅读(749) | 评论(0) | 转发(0) |
0

上一篇:AddFolderIcon

下一篇:AdminAskPath

给主人留下些什么吧!~~