BlueMonkMN
BlueMonkMN

Reputation: 25601

How does the SetTargetPath event in InstallShield Basic MSI work?

I have a product that needs to install to multiple drives and directories, some of which can be customized. So I'm looking at how directories are changed at run-time in an InstallShield Basic MSI project. I see that the DestinationFolder and InstallChangeFolder dialogs work together to change the INSTALLDIR directory using a SetTargetPath event on the OK button press of InstallChangeFolder.

What I don't understand is why there is only one parameter to SetTagetPath. The MsiSetTargetPath function takes 2 parameters in addition to the installation handle, so I don't understand why the SetTargetPath event only takes 1. I want to set a specified directory variable to refer to the specified directory. That requires two parameters. How are they getting by with just one parameter?

I have read the documentation on SetTargetPath 3 times and it still doesn't make sense.

Upvotes: 1

Views: 713

Answers (2)

Christopher Painter
Christopher Painter

Reputation: 55601

You want to research "file costing" (Cost Initialize, Cost Finalize). Prior to costing you can use a Type 51 Set Property custom action. After costing you have to use a Type 35 Set Directory custom action. This is because costing needs to be recalculated.

I've noticed you've got a lot of MSI questions. You might want to pick up a book such as Phil Wilson's The Definitive Guide to Windows Installer. That and mentors are the best sources of information because there is so little training available in this area.

Upvotes: 0

BlueMonkMN
BlueMonkMN

Reputation: 25601

It appears that the purpose of SetTargetPath is to transfer an updated value in a property to the directory variable of the same name, performing some validations on the old and new values (in the directory variable and property value respectively) in the process. Therefore it seems that transferring a new value into a directory variable takes place in two steps:

  1. Set a property of the same name to the new value.
  2. Call SetTargetPath providing the property name to copy the value from teh property into the directory.

In doing this, be aware that if the property is provided is brackets, it will be expected to reference another property name. So if the value to be copied to a directory variable is directly in the property, do not use brackets.

Upvotes: 1

Related Questions