RegDBGetKeyValueEx Example

InstallShield 2013 ยป 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 RegDBSetKeyValueEx and RegDBGetKeyValueEx

* functions.


* RegDBCreateKeyEx is called to create a test subkey in the

* HKEY_CLASSES_ROOT key.  The value of a key is set in integer

* form using the REGDB_NUMBER option of the RegDBSetKeyValueEx

* function.  After this value is set, it is retrieved using

* the RegDBGetKeyValueEx function and verified.




#define TITLE "RegDBSetKeyValueEx & RegDBGetKeyValueEx"


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

#include "Ifx.h"


export prototype ExFn_RegDBGetKeyValueEx(HWND);


function ExFn_RegDBGetKeyValueEx(hMSI)

    STRING szKey, szNumName, szNumValue, svNumValue, szTitle, szMsg;

    NUMBER nType, nSize, nvType, nvSize;



    // Create a key to test.

    szKey = "TestKey";


    if (RegDBCreateKeyEx (szKey, "") < 0) then

        MessageBox ("RegDBCreateKeyEx failed.", SEVERE);




    // Set up parameters for call to RegDBSetKeyValueEx.

    szNumName  = "TestValue";

    szNumValue = "12345";

    nType      = REGDB_NUMBER;

    nSize      = -1;


    // Set a key name and a value associated with it.

    if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue,

                           nSize) < 0) then

        MessageBox ("RegDBSetKeyValueEx failed.", SEVERE);



        // Display what RegDBSetKeyValueEx has done.

        szMsg = "%s set to: %s";

        SprintfBox (INFORMATION, TITLE, szMsg, szNumName, szNumValue);



    // Retrieve key value information.

    if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue,

                           nvSize) < 0) then

        MessageBox ("RegDBGetKeyValueEx failed.", SEVERE);


        // Check to see if the value returned is the same as the value set.

        if (nvType != REGDB_NUMBER) then

            MessageBox ("Type comparison failed.", SEVERE);



        if (svNumValue != szNumValue) then

            MessageBox ("Subkey value comparison failed.", SEVERE);



        // Display what RegDBGetKeyValueEx retrieved.

        szMsg = "%s has value: %s\n\nThis data is %d bytes.";

        SprintfBox (INFORMATION, TITLE, szMsg, szNumName, svNumValue, nvSize);



    // Delete the created test key.

    if (RegDBDeleteKey (szKey) < 0) then

        MessageBox ("RegDBDeleteKey failed.", SEVERE);