cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gomochainstall
Level 6

Use INSTALLDIR in Custom Action InstallScript

Jump to solution

Hello everyone,

I have the following InstallScript, running as a deferred custom action in System Context (not even sure if this is required):

 

 

#define TITLE "RegDBSetKeyValueEx & RegDBGetKeyValueEx"
#include "Ifx.h"

export prototype CreateCompanyInstallDirRegistryKeyAndSetValue(HWND);

function CreateCompanyInstallDirRegistryKeyAndSetValue(hMSI)

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

    NUMBER nType, nSize, nvType, nvSize;

begin

 

    // Create a key to test.

    szKey = "Gomocha";

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

        MessageBox ("RegDBCreateKeyEx failed.", SEVERE);

        abort;

    endif;

 

    // Set up parameters for call to RegDBSetKeyValueEx.

    szNumName  = "InstallDir";

    szNumValue = INSTALLDIR;

    nType      = REGDB_STRING;

    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);

        abort;

    else

        // Display what RegDBSetKeyValueEx has done.

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

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

    endif;

 

    // Retrieve key value information.

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

                           nvSize) < 0) then

        MessageBox ("RegDBGetKeyValueEx failed.", SEVERE);

    else

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

        if (nvType != REGDB_NUMBER) then

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

        endif;

 

        if (svNumValue != szNumValue) then

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

        endif;

 

        // Display what RegDBGetKeyValueEx retrieved.

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

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

    endif;

end;

 

 

Unfortunately, INSTALLDIR is empty and the registry value as a result, is also empty. How do I get the INSTALLDIR property? I thought it was a built-in property so I didn't need to do anything else. 

Labels (1)
0 Kudos
(1) Solution
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

To access installdir or any public property in deferred custom action you need to use CustomActionData 

Please refer below help link to access INSTALLDIR in Deferred CA

https://docs.revenera.com/installshield23helplib/helplibrary/AccessingProps-DeferredCAs.htm

View solution in original post

(2) Replies
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

To access installdir or any public property in deferred custom action you need to use CustomActionData 

Please refer below help link to access INSTALLDIR in Deferred CA

https://docs.revenera.com/installshield23helplib/helplibrary/AccessingProps-DeferredCAs.htm

varul
Revenera Moderator Revenera Moderator
Revenera Moderator

You can also refer the sample attached in this community post by josh, 

https://community.flexera.com/t5/InstallShield-Forum/Could-not-get-the-INSTALLDIR-value-using-the-Deferred-custom/m-p/22600

 
 

 

0 Kudos