0

Can I call a function from a DLL (custom action) to search for the location a program is already installed on and install my msi there?

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Natalie Carr
  • 3,707
  • 3
  • 34
  • 68

1 Answers1

-1

You don't need a custom action in this case. Use DirectorySearch / FileSearch elements WiX provides out of the box. Besides, if that program leaves a trace in system registry, RegistrySearch element is useful.

UPDATE: As far as I understand from your comments below, you have the ready-made function for detecting the path the main program was installed to, and you'd like to utilize this functionality to install extra add on there.

You should author an immediate custom action (CA) which calls a function from a DLL and schedule it somewhere between AppSearch and LaunchConditions. This custom action should save the result into an MSI property, for example, INSTALLLOCATION. This means if you have a function which returns a path, you might want to wrap it into another function (the actual CA) which will just save that value to INSTALLLOCATION property.

You can then use this property in your directory structure like this:

  <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="INSTALLLOCATION" Name="my app">
     ...
     </Directory>
  </Directory>

NOTE: Following this advice still requires some basic knowledge about Windows Installer and WiX, so I strongly recommend you to address MSDN and WiX tutorial for basics.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • Hello, Thanks for getting back to me, I have the dll written and have to call another dll function also and would like to call these two at the same time. Thanks – Natalie Carr Jul 20 '12 at 13:52
  • Also because there are numerous places a customer may have installed it to...:) – Natalie Carr Jul 20 '12 at 13:57
  • If you still need to call functions from a DLL, [this tutorial chapter is a good start](http://wix.tramontana.co.hu/tutorial/events-and-actions/whats-not-in-the-book). As I mentioned in a comment to your another question, start from reading tutorial – Yan Sklyarenko Jul 20 '12 at 13:58
  • Thanks again, I know i have been using that specific tutorial and have gotton as far as writing the custom action etc, What im failing to grasp is pulling out the variables for the registry search and placing them into my wix file. – Natalie Carr Jul 20 '12 at 14:08
  • [This is a good example](http://wix.sourceforge.net/manual-wix3/read_a_registry_entry.htm). It is also available in WiX.chm – Yan Sklyarenko Jul 20 '12 at 14:29
  • Il try to explain better what i need to achieve. My customers will have a certain program installed but every customer has it as a different names that i dont have access to. My dll function checks all of the possibilities that it could be under and installs this new add on to that same location. I have my dll function called but i do not know where to go from here? I hope I have explained myself better as I am new to wix. – Natalie Carr Jul 23 '12 at 08:45
  • Ok, I think I understand what you mean. I'll update my answer – Yan Sklyarenko Jul 23 '12 at 09:01
  • Thank You very much, it is muchly appreciated..:) – Natalie Carr Jul 23 '12 at 09:05
  • Thanks again, still alittle lost as I am so new to this, has to be done for friday so i may get digging..:) thanks – Natalie Carr Jul 23 '12 at 10:34