RegDBDeleteKey Example

InstallShield 2020 ยป 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 RegDBDeleteKey function.

*

* This example creates and then deletes a registry key.

* Almost all of the examples provided with the registry functions

* use this function to delete a key. Please refer to those

* examples for more information.

*

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

 

#define TITLE_TEXT "RegDBDeleteKey Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_RegDBDeleteKey(HWND);

 

function ExFn_RegDBDeleteKey(hMSI)

    STRING szKey, szClass, szKeyRoot, szMsg, svLogFile;

    NUMBER nResult1, nResult2;

begin

 

    // Set up parameters for call to RegDBCreateKeyEx.

    szKey   = "DeleteMeKey";

    szClass = "";

 

    // Create a key with no class value.

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

        MessageBox ("RegDBCreateKeyEx failed.", SEVERE);

        abort;

    else

        SprintfBox (INFORMATION, TITLE_TEXT, "%s successfully created.", szKey);

    endif;

 

    // Call RegDBDeleteKey to delete the key just created.

    if (RegDBDeleteKey (szKey) < 0) then

        MessageBox ("RegDBDeleteKey failed.", SEVERE);

    else

        SprintfBox (INFORMATION, TITLE_TEXT, "%s successfully deleted.", szKey);

    endif;

 

end;