Creating a line in the registration database in Windows, and the Using/changing this value?

Ok. First of I am creating an application which does a lot of communication with a database. Several databases actually, and what I would like to do is have a couple of lines in the registry which contains the IP of these databases.
Say,
key Production=10.10.10.10
key Report=10.10.10.11
key Distributing=10.10.10.12

How do I create these using the windows installer

How do I use this information in a connection from the program to a server

How can I change this if the IP changes of one of these servers

I don't know if this is the best solution, but I think the information is good to know stuff anyhow.
Different ideas are welcome, but I think this is the way I want to do it.

Sune



Answer this question

Creating a line in the registration database in Windows, and the Using/changing this value?

  • kenniejaydavis

    Touch the registry for apps parameters is a bad practice, use app.config instead ;D

    http://msdn2.microsoft.com/en-us/library/aa730869(VS.80).aspx

    Regards.


  • RavindraPatil

    See in Properties.Settings.Default......

    Example:



    <applicationSettings>
      <ClienteHC.Properties.Settings>
       <setting name="ServidorIP" serializeAs="String">
        <value>192.168.1.5</value>
       </setting>
      </ClienteHC.Properties.Settings>
     </applicationSettings>

     




    string srvIP = Properties.Settings.Default.ServidorIP

     


    Regards.


  • BarryK

    OK, so if I add a App.config to my solution, and ad this:

    <configuration>
    <appSetting>
    <add key="ProductionServer" value="//10.10.10.10"/>
    <add key="ReportServer" value="//10.10.10.11"/>
    <add key="DistributionServer" value="//10.10.10.12"/>
    </appSetting>
    </configuration>

    I see that this config file is in my final build where I can easily edit these. So that is good. Question now for me is how do I get ahold of this information from the program If I wanted to display it in a form for instance

    Sune




  • Creating a line in the registration database in Windows, and the Using/changing this value?