With Visual Studio Setup Project I can ask for the user for some input, like a location of a folder. There is any way for the installed application to read the user input?
views:
97answers:
4I haven't tried this, but I can think you can write to the Windows' Registry at installation time and read it at runtime.
You could pass the provided location to a custom install action and do whatever you wanted with the value that the user provided your custom installer action with. Save to text file, config file, registry, whatever...
Just pass the value that the user selected through CustomActionData to your custom install action and read it in during OnInstall.
http://msdn.microsoft.com/en-us/library/2w2fhwzz%28VS.80%29.aspx provides detail how to pass data into your custom install action.
Then when you launch your application you can just read from the known location whatever it may be.
There is a couple of ways ...
- the installation program can write a config file in a certain location that can then be read by the application (typical for older windows versions and linux variants)
- for windows programs, the registry is the preferred way of writing and reading such information (until MS comes up with a new way of doing these things). Every application gets a "typical" path in the registry, and can read write to it. This does not only apply to information set by the user during the installation, but also a lot of config stuff.
Not sure what your question is aiming at, though .. It sounds like you have a specific scenario in mind.
The simplest way to do that would be to store the value in the Registry:
Right-click your setup project and select View -> User Interface
Add a new dialog under Install and move it to the correct position within the sequence
Each control in a dialog has a property called Property, e.g. Edit1Property or ButtonProperty. The name of this property should be some unique value, by default it will be something like EDITA1. We will use this property name later to refer to the value of the control.
Right-click your setup project and select View -> Registry
Navigate to
HKCU\Software\[Manufacturer]
or toHKCU\Software\[Manufacturer]
depending on whether you want to store this setting for the current user only or machine wide. You can also create a new entry under User/machine hive. Then the entry will be stored either under HKCU or under HKLM depending on whether the installation is per-user or per-machine.Create a new value under the key selected in 5. In the properties view of that value enter the property name of the control that has been specified in step 3. This name has to be in square bracket, for example [EDITA1] and you are done.