Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Setting a Property value in CA doesn't work


6 replies to this topic

klee777

klee777
  • Full Members
  • 21 posts

Posted 19 April 2006 - 22:48

Hi, I saw Stefan answered to someone who tried a standard DLL as CA that InstallShield simply uses an MSI DLL wrapper. So I decided not to use it but to use MSI DLL.
I got "Learning MSI Projects Using FLEXnet InstallShield 11.5" and followed the steps exactly described in Ch.7.

- Created a custom property "MYPROPERTY" under Property Manager
- Created CA with "New Set Property", changed the action name to "SetMYPROPERTY", Property Name to "MYPROPERTY" and Property Value to "1"
- Added this CA to the proper Execution Sequence, e.g. "After RegisterProduct"

But this doesn't change the value of MYPROPERTY during install. I even debugged it and the value of MYPROPERTY remains as the initial value, i.e. "0".

To make it worse, right after that sequence (i.e. "After SetMYPROPERTY"), I added MSI DLL CA, which only calls MsiGetProperty() and displays the value of MYPROPERTY, such as,

CODE
/////////////////////////////////////////////////////////////////////////////
....
UINT __stdcall GetMYPROPERTY( MSIHANDLE hMSI )
{
   char szMyProp[MAX_PATH];
   DWORD dwSize = MAX_PATH;
   UINT uiStat = MsiGetProperty( hMSI, _T("MYPROPERTY"), szMyProp, &dwSize );
   ::MessageBox( NULL, szMyProp , _T("MYPROPERTY Property"), MB_OK );
   if( ERROR_SUCCESS != uiStat || strlen( szMyProp ) == 0 )
       return ERROR_INSTALL_FAILURE;
   else
       return ERROR_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////


and the messageBox displays complete blank, not even "0".

In other words, I am facing two problems;
1. Prop value is not assigned in SetMYPROPERTY CA.
2. Even the initial Prop value is gone when called by MSI DLL.

Can you advise me what I did wrong?

TIA.
- Kyle

Edited by klee777, 19 April 2006 - 22:59.


antyagi

antyagi
  • Full Members
  • 121 posts

Posted 20 April 2006 - 05:18

_T and char at same place you probably should look again at your code.
Instead of declaring 'szMyProp' as char declare it as
CODE
_TCHAR szMyProp[MAX_PATH];
also use _tcslen instead of strlen.
  ankur tyagi

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 April 2006 - 11:27

Where exactly do you set the property (immediate or deferred action?) and where do you try to read it? Note that property values are not passed from the Execute sequence back to the UI sequence.

klee777

klee777
  • Full Members
  • 21 posts

Posted 20 April 2006 - 14:34

Thank you Stefan for your reply.

> Where exactly do you set the property (immediate or deferred action?)

CA name is "setMYPROPERTY".
According to the training manual, the property set by "New Set Property" is forced to set "immediate" so it is read-only, meaning that I am not even allowed to change the value of "In-Script Execution"; it is always "immediate".
And its Install Sequence is "Install Exec Sequence" with "After RegisterProduct" action.

> where do you try to read it?

Its "In-Script Execution" is set to "Commit Execution" and
Install Sequence is "Install Exec Sequence" with "After setMYPROPERTY" action.

Attached is my full source project.

I'm desparate so I really appreciate your time / advice.

- Kyle

Attached Files



klee777

klee777
  • Full Members
  • 21 posts

Posted 20 April 2006 - 14:37

QUOTE (antyagi @ 2006-04-20 05:18)
_T and char at same place you probably should look again at your code.
Instead of declaring 'szMyProp' as char declare it as
CODE
_TCHAR szMyProp[MAX_PATH];
also use _tcslen instead of strlen.

Thanks for pointing it out. Since my DLL was compiled with _MBCS pre-definition, it shouldn't affect.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 April 2006 - 13:57

Commit actions are a special case of deferred action, so the property access restrictions apply. See CustomActionData in MSI help for a possible workaround.

klee777

klee777
  • Full Members
  • 21 posts

Posted 26 April 2006 - 20:34

Thanks a lot Stefan. Since we have the maintenance plan from Macrovision, I contacted them, and they told me exactly what you said. It is working.

Here is how I did:
- after those three steps, I had to create one more CA using "New Set Property", e.g. setMYPROPERTY2, whose Property Name is MSI DLL CA name, and Property Value is [MYPROPERTY].
- in CPP, I had to change the property name from "MYPROPERTY" to "CustomActionData", such as,
CODE
/////////////////////////////////////////////////////////////////////////////
UINT __stdcall GetMYPROPERTY( MSIHANDLE hMSI )
{
   char szMyProp[MAX_PATH], szSys[MAX_PATH];
   DWORD dwSize = MAX_PATH;
   UINT uiStat;
   uiStat = MsiGetProperty( hMSI, _T("CustomActionData"), szMyProp, &dwSize );

   if( ERROR_SUCCESS != uiStat || strlen( szMyProp ) == 0 )
       return ERROR_INSTALL_FAILURE;
   else{
       HKEY hKey;
       LONG nRC;
       nRC = RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software"), 0,
                          KEY_READ | KEY_WRITE, &hKey );
       nRC = RegSetValueEx( hKey, _T("MYPROPERTY in GetMYPROPERTY"), 0,
                          REG_SZ, (LPBYTE)szMyProp, (strlen(szMyProp)+1) );
       RegCloseKey( hKey );

       return ERROR_SUCCESS;
   }
}

/////////////////////////////////////////////////////////////////////////////



The reason I changed ::MessageBox() to RegSetValueEx() is,
for some reason, the following statement always displays an empty string, while RegXX() can write the string in the registry:
CODE

   ::MessageBox( NULL, szMyProp , _T("MYPROPERTY Property"), MB_OK );


Since Macrovision tech support told me it is beyond the scope of their support, I'd like to know if displaying an empty string is the way MessageBox() does in MSI DLL.

Stefan,
Do you know?

Thanks again.
- Kyle