InstallShield 中如何写注册表信息

     InstallShield 中如何写注册表信息,我写的是当前版本信息与软件的安装路径。

 

     首先当然要找到注册表中的位置,一般软件会在注册表中直接设置好路径。然后在程序中直接拼出来就可了。我的注册表路径就是name+company name.

 

     RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );  // 需要在 MACHINE 下面写

 

     szKey = "SOFTWARE//Name//CompanyName";      // 在此目录下写当前版本信息

 

     // IFX_PRODUCT_VERSION 就是你在 General Information 中填入的 version

     RegDBSetKeyValueEx( szKey, "currentversion", REGDB_STRING, IFX_PRODUCT_VERSION, -1 );  //current version

 

     szKey = szKey + "//";

 

     // 在上面目录下面再建一个目录 以软件的版本名字命名
     szKey = szKey + IFX_PRODUCT_VERSION; 


     szKeyName = "RootDirectory";

    

     //TARGETDIR 相信大家都知道了 就是你选择的路径。
     RegDBSetKeyValueEx( szKey, szKeyName, REGDB_STRING, TARGETDIR, -1 );  //write the RootDir 

 

 

     PS: RegDBSetKeyValueEx() 的用法。

    

    

     RegDBSetKeyValueEx ( szKey, szName, nType, szValue, nSize );

 

 

Parameters

RegDBSetKeyValueEx Parameters 

Parameter

Description

szKey

Specifies the name of the key to set; the key must already have been created with RegDBCreateKeyEx. You do not have to include the HKEY_CLASSES_ROOT key (or another specified key) in this parameter. Separate different levels in the subkey with a double backslash (//).

szName

Specifies the value name for the value data to set be set. To set the default value of the key specified in szKey, pass a null string (“”) in this parameter.

nType

Specifies the type of data to be set. Pass one of the following predefined constants in this parameter:

  • REGDB_STRING—A string variable, no newline characters allowed.
  • REGDB_STRING_EXPAND—A string variable holding an expandable environment variable expression, such as "%MYPATH%".
  • REGDB_STRING_MULTI—A string variable, newline characters allowed.
  • REGDB_NUMBER—A number expressed as a string and passed in string variable. Creates data of type DWORD. When nType is REGDB_NUMBER, passing a decimal string in szValue results in a numeric value being stored in the registry. This numeric value is then displayed as a hexadecimal number followed by its decimal equivalent in parentheses. You cannot pass a hexadecimal number in the string in szValue—it must be a decimal number.
  • REGDB_BINARY—Binary data stored in a string.

szValue

Specifies the value to associate with the value name. All values must be passed as string variables. Numbers must be expressed as strings. InstallShield converts them to numbers internally.

nSize

Specifies the size—in bytes—of the data to be set. You can specify -1 in this parameter when nType is REGDB_STRING, REGDB_STRING_EXPAND, or REGDB_NUMBER, and InstallShield will set the size. However, with REGDB_BINARY and REGDB_STRING_MULTI, you must always specify the number of bytes of binary data that you are storing.

 

Return Values

RegDBSetKeyValueEx Return Values 

Return Value

Description

0

Indicates that the function successfully set the key.

< 0

Indicates that the function was unable to set the key.

 

 

你可能感兴趣的:(String,function,Parameters,Numbers,Constants,newline)