PDA

View Full Version : help needed on setting property calling function in standard DLL from custom action



WISeAgent
05-19-2004, 09:04 PM
Greetings,

I'm using installshield developer 7.04 and for some reason, my custom actions have to be performed in a DLL. One of my custom action is to set a property value using MsiGetProperty and it is implemented in a standard DLL. I got no problem invoking the function from my install project, but MsiSetProperty function failed. I've tried to get property value using MsiGetProperty and it also failed.

I was wondering can I get/set property value in a standard DLL or install shield DLL, and have anyone out there has done it successfully?

The function in my DLL is something like:
DllExport UINT __stdcall GetCPUReservation(MSIHANDLE hInstall)
{
TCHAR szValueBuf[MAX_PATH];
DWORD dwBuffer = sizeof(szValueBuf)/sizeof(TCHAR);
UINT uiMsiRc = MsiGetProperty(hInstall, TEXT("LOCALSYSTEM_CPURESERVATION"), szValueBuf, &dwBuffer);
if (ERROR_SUCCESS != uiMsiRc)
{
// pop up a msg box
}
return 1;
}


Regards,
WWang

_doog_
05-21-2004, 08:14 AM
+) yes it works... :)
+) you have to ensure that your custom action is marked as immediate (that it is not deferred) - cause deferred CAs can access only a very limited set of properties
+) the actual return value (uiMsiRc) and the value of dwBuffer returned could be helpful to debug the problem

WISeAgent
05-21-2004, 08:37 AM
Thank for the confirmation, at least I knew I'm still on the right track;-)

I did manged to call a DLL function from my standard project CA and both msiGetProperty and msiSetProperty returns ERROR_SUCCESS. I found it out by calling a msgbox to display property value in the DLL, if the msiGetProperty call success. It'll display an err msg when failed.

What I don't understand is that when I call the same DLL function from a CA in my merge module project, no msg box was poped up at all. But I'm sure the DLL function has been called as I could find it from the install log file and the CA return value is 0. I can't determine if the msiSetProperty in my DLL is success or not. I've also tried to assign the property value to a windows registry value, but the value supposed to be set in the DLL wasn't show up in the windows registry after installation. btw, I've set the sequence number for the CA to 730. right after the InstallInitialized, which is 700.

Any suggestions?


Regards,
WWang

_doog_
05-21-2004, 08:48 AM
and you could verify with your log-file that the ca is called at the right position?

WISeAgent
05-24-2004, 09:38 PM
Originally posted by _doog_
and you could verify with your log-file that the ca is called at the right position?

Actually, that brings up another question. I seems don't have much control over the CA sequence;-)

I've got a CA and I've given is a value of 2811, which is very close to "InstallFinalize" which has a value of 2850. in my CA, it used a file from a component to be installed. From the installation log, I've noticed that my CA is called before the FileCopy action of the file to be used by the CA. I was wondering if it is normal to have a CA after "InstallFinalize", or there is a better way to do it?

The relevant log enclosed:

-----------------------8<----------- log starts--------
MSI (s) (E8:2C): Doing action: LoadPerfCounter
Action start 11:52:15: LoadPerfCounter.
Action ended 11:52:15: LoadPerfCounter. Return value 0.

[snap...]

MSI (s) (E8:2C): Executing op: FileCopy(SourceName=xxxx|xxxperf.ini,SourceCabKey=xxxperf.ini.6ACBB81A_4DD0_4685_AF9D_4115665925C4,DestName=xxxperf.ini,Attributes=16384,FileSize=2557,PerTick=32768,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=-962338120,HashPart2=1249951257,HashPart3=-1228523194,HashPart4=1404733982,)
MSI (s) (E8:2C): File: C:\Program Files\xxx\Foo\bin\xxxperf.ini; To be installed; No patch; No existing file
MSI (s) (E8:2C): Source for file xxxperf.ini.6ACBB81A_4DD0_4685_AF9D_4115665925C4' is compressed
-----------------------8<----------- log ends--------



Now, come back to be orginal queation about setting property in a DLL from merge module, I might have to explain a bit more about what I'm going to do and I'd like to have your advice.

In my CA, what I really want to do is to set a value to a poperty,that's call it "blah", using msiSetProperty function call. I've also got a component in my merge module, which has a windows registry string and it's value is [blah] and I'm expecting it to use the value assigned by my CA. The value supposed to be assigned by the CA is not written to the windows registry, I got not idea if the CA failed to assign value to a property, or the Value assigned by CA is done after the windows registry value has been written already.

I've tried to pop up a msgbox in my DLL so to find out the actual status of the function calls. The pops up msg works fine what the DLL is called from a CA in standard project, but nothing is getting poped up when it is called from a CA in a merge module. I wont have any idea if the value has been assigned or not.

Any suggestions?

_doog_
05-25-2004, 07:32 AM
first of all, to bring your CA into the right order during install, go to the direct editor of the merge module

use the tables ModuleInstallExecuteSequence and ModuleInstallUISequence to specify the sequencing of your CA relative to other CAs

to your problem:
if i understand it right, you want to have your CA calculate a property value and write that to the registry...

best way would be:
make your CA immediate and sequence it ASAP after InstallInitialize.
To write your Property to the registry, use the registry section of InstallShield, you can specify property values there with the name of the property in square brackets - []

WISeAgent
05-30-2004, 08:39 PM
It turned out that my CA is not getting executed at all due to it's not added properly to the ModuleInstallExecuteSequence table. It's working properly after I put it just before "InstallFinalize" event.

Thank you to all who's giving me advices about the problem. It's really appreciated.


Regards,
WWang