<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Installation Developer &#187; How to Work with Configuration Files, Part 1</title>
	<atom:link href="http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.installationdeveloper.com</link>
	<description>InstallShield Training - InstallShield Tutorials</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:57:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Work with Configuration Files, Part 1</title>
		<link>http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/</link>
		<comments>http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 18:35:10 +0000</pubDate>
		<dc:creator>Rod_Maupin</dc:creator>
				<category><![CDATA[InstallShield Training]]></category>

		<guid isPermaLink="false">http://www.installationdeveloper.com/?p=339</guid>
		<description><![CDATA[
A reader emailed me with questions about configuration files.&#160; How to create them, and how to read from them, both during install time.&#160; I will cover how to create configuration files in this post, which is Part 1.&#160; I will cover how to read from configuration files in the next post, which will be Part [...]]]></description>
			<content:encoded><![CDATA[<p>
A reader emailed me with questions about configuration files.&nbsp; How to create them, and how to read from them, both during install time.&nbsp; I will cover how to create configuration files in this post, which is <strong>Part 1</strong>.&nbsp; I will cover how to read from configuration files in the next post, which will be <strong>Part 2</strong>.
</p>
<p>
Creating a configuration file is very easy in the <strong>InstallShield IDE</strong>, however it is different based on whether you are working in a <strong>Basic MSI</strong> or <strong>InstallScript</strong> project.
</p>
<p>
Here is how to create a configuration file in a <strong>Basic MSI</strong> project:
</p>
<ol>
<li>
<div>
	Go to the <strong>System Configuration</strong> group, <strong>INI File Changes</strong> view, and in the middle pane right-click <strong>INI Files</strong> and select <strong>Add INI&nbsp;File</strong>.
	</div>
</li>
<li>
<div>
	Rename the&nbsp;.ini file to whatever you&nbsp;want.&nbsp; In&nbsp;this case, it will be <strong>Mega View.ini</strong>.&nbsp; Now, if you click on the <strong>Mega View.ini</strong> node, you will see the properties for the file.&nbsp; You will see the <strong>Display Name</strong>, the <strong>Component</strong> the configuration file belongs to, and the <strong>Target folder</strong>, which by default will be <strong>[INSTALLDIR]</strong>.
	</div>
</li>
<li>
<div>
	Next, right-click on the .ini file node (<strong>Mega View.ini</strong>) and select <strong>Add Section</strong>.
	</div>
</li>
<li>
<div>
	Rename the section to whatever you want.&nbsp; In this case, it will be <strong>general</strong>.
	</div>
</li>
<li>
<div>
	Next, right-click on the section node (<strong>general</strong>) and select <strong>Add Keyword</strong>.
	</div>
</li>
<li>
<div>
	Rename the keyword to whatever you want.&nbsp; In this case, it will be <strong>title</strong>.
	</div>
</li>
<li>
<div>
	Next, click on <strong>title</strong>, and in the right pane, set the <strong>Display Name</strong>, <strong>Action</strong>, and <strong>Data Value</strong> properties.&nbsp; Here are the values we will enter:
	</div>
<ol>
<li>
<div>
		Display Name: <strong>title</strong>
		</div>
</li>
<li>
<div>
		Action: <strong>Replace Old Value</strong>
		</div>
</li>
<li>
<div>
		Data Value: <strong>Mega View &#8211; The Ultimate Viewer</strong>
		</div>
</li>
</ol>
</li>
</ol>
<p>
Now, when you build and&nbsp;run your <strong>Basic MSI</strong> install, the <strong>Mega View.ini</strong> file will be created in the <strong>INSTALLDIR</strong> folder.&nbsp; The file will look like this:
</p>
<blockquote>
<p>
	<strong>[general]<br />
	title=Mega View &#8211; The Ultimate Viewer</strong>
	</p>
</blockquote>
<p>
That is how you create a configuration file in a <strong>Basic MSI project</strong>.&nbsp; Now, let&#39;s look at how to do it in an <strong>InstallScript</strong> project.
</p>
<p>
In an <strong>InstallScript</strong> project, you will have to create the configuration file from within the script.&nbsp; The function you use for this is <strong>WriteProfString()</strong>.&nbsp; Here is how the call to <strong>WriteProfString</strong> would look for <strong>Mega View.ini</strong>.&nbsp; We&#39;ll assume we want to write the same exact file that we did in the <strong>Basic MSI</strong> project:
</p>
<blockquote>
<p>
	if (WriteProfString(TARGETDIR ^ &quot;Mega View.ini&quot;,<br />
	&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@IDS_MEGAVIEWINI_SECTION,<br />
	&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@IDS_MEGAVIEWINI_KEY,<br />
	&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@IDS_MEGAVIEWINI_VALUE) &lt; 0) then<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SprintfBox(SEVERE,&quot;WriteProfString&quot;,&quot;Mega View.ini could not be created&quot;);<br />
	&nbsp;endif;
	</p>
</blockquote>
<p>
Let&#39;s look at the function parameters.&nbsp; <strong>TARGETDIR</strong> is the main installation folder for the <strong>InstallScript</strong> installation.&nbsp; Here we are building a path to the <strong>Mega View.ini</strong> file.&nbsp; Next, there are three parameters that are entries from the <strong>String Table</strong>.&nbsp; Let&#39;s look at each of these values:
</p>
<blockquote>
<p>
	IDS_MEGAVIEWINI_SECTION: <strong>general</strong><br />
	IDS_MEGAVIEWINI_KEY: <strong>title</strong><br />
	IDS_MEGAVIEWINI_VALUE: <strong>Mega View &#8211; The Ultimate Viewer</strong>
	</p>
</blockquote>
<p>
You also&nbsp;see a <strong>SprintfBox()</strong> call that displays an error message if the <strong>Mega View.ini</strong> file couldn&#39;t be created.
</p>
<p>
When the <strong>InstallScript</strong> installation is run, the <strong>Mega View.ini</strong> file will be created and will look the same as for the <strong>Basic MSI</strong> project.
</p>
<p>
That is how to create a configuration file in both <strong>Basic MSI</strong> and <strong>InstallScript</strong> projects.&nbsp; In <strong>Part 2</strong>, we will look at how to read a configuration file at install time.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;bodytext=%0D%0AA%20reader%20emailed%20me%20with%20questions%20about%20configuration%20files.%26nbsp%3B%20How%20to%20create%20them%2C%20and%20how%20to%20read%20from%20them%2C%20both%20during%20install%20time.%26nbsp%3B%20I%20will%20cover%20how%20to%20create%20configuration%20files%20in%20this%20post%2C%20which%20is%20Part%201.%26nbsp%3B%20I%20will%20cover%20how%20" title="Digg"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;notes=%0D%0AA%20reader%20emailed%20me%20with%20questions%20about%20configuration%20files.%26nbsp%3B%20How%20to%20create%20them%2C%20and%20how%20to%20read%20from%20them%2C%20both%20during%20install%20time.%26nbsp%3B%20I%20will%20cover%20how%20to%20create%20configuration%20files%20in%20this%20post%2C%20which%20is%20Part%201.%26nbsp%3B%20I%20will%20cover%20how%20" title="del.icio.us"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;t=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="Facebook"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;h=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="NewsVine"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="Reddit"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="StumbleUpon"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;annotation=%0D%0AA%20reader%20emailed%20me%20with%20questions%20about%20configuration%20files.%26nbsp%3B%20How%20to%20create%20them%2C%20and%20how%20to%20read%20from%20them%2C%20both%20during%20install%20time.%26nbsp%3B%20I%20will%20cover%20how%20to%20create%20configuration%20files%20in%20this%20post%2C%20which%20is%20Part%201.%26nbsp%3B%20I%20will%20cover%20how%20" title="Google Bookmarks"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;submitHeadline=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;submitSummary=%0D%0AA%20reader%20emailed%20me%20with%20questions%20about%20configuration%20files.%26nbsp%3B%20How%20to%20create%20them%2C%20and%20how%20to%20read%20from%20them%2C%20both%20during%20install%20time.%26nbsp%3B%20I%20will%20cover%20how%20to%20create%20configuration%20files%20in%20this%20post%2C%20which%20is%20Part%201.%26nbsp%3B%20I%20will%20cover%20how%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201%20-%20http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F" title="Twitter"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F" title="Technorati"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="Live"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;source=Installation+Developer+InstallShield+Training+-+InstallShield+Tutorials&amp;summary=%0D%0AA%20reader%20emailed%20me%20with%20questions%20about%20configuration%20files.%26nbsp%3B%20How%20to%20create%20them%2C%20and%20how%20to%20read%20from%20them%2C%20both%20during%20install%20time.%26nbsp%3B%20I%20will%20cover%20how%20to%20create%20configuration%20files%20in%20this%20post%2C%20which%20is%20Part%201.%26nbsp%3B%20I%20will%20cover%20how%20" title="LinkedIn"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;t=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201" title="MySpace"><img src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
