<?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>Thu, 26 Jan 2012 22:12:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<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>
<!-- Start Sociable --><div class="sociable"><div class="sociable_tagline"><a class='sociable_tagline' target='_blank' href='http://blogplay.com' style='color:#333333;text-decoration:none'>Be Sociable, Share!</a></div><ul class='clearfix'><li><a title="Twitter" class="option1_32" style="background-position:-288px -32px" rel="nofollow" target="_blank" href="http://twitter.com/intent/tweet?text=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%20(via%20@sociablesite)"></a></li><li><a title="Facebook" class="option1_32" style="background-position:-96px 0px" 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"></a></li><li><a title="email" class="option1_32" style="background-position:-160px 0px" rel="nofollow" target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to&su=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&body=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&ui=2&tf=1&shva=1"></a></li><li><a class="option1_32" style="cursor:pointer;background-position:-128px 0px" rel="nofollow" title="Add to favorites - doesn't work in Chrome"  onClick="javascript:AddToFavorites();"></a></li><li><a title="StumbleUpon" class="option1_32" style="background-position:-224px -32px" 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&title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201"></a></li><li><a title="Delicious" class="option1_32" style="background-position:-32px 0px" 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"></a></li><li><a title="Google Reader" class="option1_32" style="background-position:-224px 0px" rel="nofollow" target="_blank" href="http://www.google.com/reader/link?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;srcURL=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;srcTitle=Installation+Developer+InstallShield+Training+-+InstallShield+Tutorials"></a></li><li><a title="LinkedIn" class="option1_32" style="background-position:-288px 0px" 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"></a></li><li><a title="BlinkList" class="option1_32" style="background-position:0px 0px" rel="nofollow" target="_blank" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&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"></a></li><li><a style="cursor:pointer" rel="nofollow" onMouseOut="fixOnMouseOut(document.getElementById('sociable-post-339'), event, 'post-339')" onMouseOver="more(this,'post-339')"><img style='margin-top:9px' src='http://www.installationdeveloper.com/wp-content/plugins/sociable/images/more.png'></a></li></ul><div onMouseout="fixOnMouseOut(this,event,'post-339')" id="sociable-post-339" style="display:none;">   

    <div style="top: auto; left: auto; display: block;" id="sociable">



		<div class="popup">

			<div class="content">

				<ul><li style="heigth:32px;width:32px"><a title="Myspace" class="option1_32" style="background-position:0px -32px" 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"></a></li><li style="heigth:32px;width:32px"><a title="Digg" class="option1_32" style="background-position:-64px 0px" 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"></a></li><li style="heigth:32px;width:32px"><a title="Reddit" class="option1_32" style="background-position:-128px -32px" 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"></a></li><li style="heigth:32px;width:32px"><a title="Google Bookmarks" class="option1_32" style="background-position:-192px 0px" 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"></a></li><li style="heigth:32px;width:32px"><a title="HackerNews" class="option1_32" style="background-position:-256px 0px" rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?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"></a></li><li style="heigth:32px;width:32px"><a title="MSNReporter" class="option1_32" style="background-position:-352px 0px" rel="nofollow" target="_blank" href="http://reporter.es.msn.com/?fn=contribute&amp;Title=How%20to%20Work%20with%20Configuration%20Files%2C%20Part%201&amp;URL=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F&amp;cat_id=6&amp;tag_id=31&amp;Remark=%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"></a></li><li style="heigth:32px;width:32px"><a title="Sphinn" class="option1_32" style="background-position:-192px -32px" rel="nofollow" target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.installationdeveloper.com%2F339%2Fhow-to-work-with-configuration-files-part-1%2F"></a></li><li style="heigth:32px;width:32px"><a title="Posterous" class="option1_32" style="background-position:-64px -32px" rel="nofollow" target="_blank" href="http://posterous.com/share?linkto=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;selection=%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"></a></li><li style="heigth:32px;width:32px"><a title="Tumblr" class="option1_32" style="background-position:-256px -32px" rel="nofollow" target="_blank" href="http://www.tumblr.com/share?v=3&amp;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&amp;s=%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"></a></li></ul>			

			</div>        

		  <a style="cursor:pointer" onclick="hide_sociable('post-339',true)" class="close">



		  <img onclick="hide_sociable('post-339',true)" title="close" src="http://www.installationdeveloper.com/wp-content/plugins/sociable/images/closelabel.png">

		  </a>

		</div>

	</div> 

  </div></div><div class='sociable' style='float:none'><ul class='clearfix'><li id="Twitter_Counter"><a href="https://twitter.com/share" data-text="How to Work with Configuration Files, Part 1 - http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/ (via #sociablesite)" data-url="http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></li><li id="Facebook_Counter"><iframe src="//www.facebook.com/plugins/like.php?href=http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:100px" allowTransparency="true"></iframe></li><li id="Google_+"><g:plusone annotation="bubble" href="http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/" size="medium"></g:plusone></li><li id="LinkedIn_Counter"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/" data-counter="right"></script></li><li id="StumbleUpon_Counter"><script src="http://www.stumbleupon.com/hostedbadge.php?s=2&r=http://www.installationdeveloper.com/339/how-to-work-with-configuration-files-part-1/"></script></li></ul></div><!-- End Sociable -->]]></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>

