<?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>Computer FAQs &#38; Tips &#187; C#</title>
	<atom:link href="http://www.computer-faqs.com/tag/csharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.computer-faqs.com</link>
	<description>Answers to your Questions, Tips to enhance your Experience</description>
	<lastBuildDate>Sun, 16 Aug 2009 23:16:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Firefox Simple Starter Program</title>
		<link>http://www.computer-faqs.com/2007/09/06/firefox-starter-program/</link>
		<comments>http://www.computer-faqs.com/2007/09/06/firefox-starter-program/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 15:04:00 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[FAQ & Tip]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://compfaqs.acpiwat.com/?p=12</guid>
		<description><![CDATA[Are you developer? or beginner to programming? You can write you own starter program and produce a new fresh Firefox.exe and Thunderbird.exe to run your portable firefox and thunderbird. Please note, if you want to walk through this article you should have done the walk with the previous articles first. When you are ready, continue [...]]]></description>
			<content:encoded><![CDATA[<p>Are you developer? or beginner to programming?<br />
You can write you own starter program and produce a new fresh <span style="font-weight: bold;">Firefox.exe</span> and <span style="font-weight: bold;">Thunderbird.exe</span> to run your portable firefox and thunderbird. Please note, if you want to walk through this article you should have done the walk with the previous articles first.</p>
<p>When you are ready, continue on..</p>
<h4>Requirements</h4>
<ul>
<li>Minimal knowledge on csharp language</li>
<li>Microsoft <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&amp;displaylang=en">.NET framework</a> installed</li>
<li>Development IDE ( <a href="http://icsharpcode.com/OpenSource/SD/Default.aspx">SharpDevelop</a> ) installed</li>
<li>Completed the walkthrough in previous articles</li>
</ul>
<p>I wrote these codes with .NET framework 2.0 installed on my machine.<br />
However it should work on .NET framework 1.0+ (not tested)</p>
<p>Ok.. let&#8217;s begin,</p>
<ul>
<li>Startup your SharpDevelop IDE</li>
<li>Create New Window Application project, let&#8217;s call it <span style="font-family: courier new;">PMozilla </span>(Portable Mozilla)</li>
<li>You should have Program.ch and a few other created automatically</li>
<li>Add new class AppStarter.ch</li>
<li>Copy and paste the following code and save it<br />
File: <code>AppStarter.ch</code></li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Diagnostics</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.ComponentModel</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> PMozilla
<span style="color: #000000;">&#123;</span>
 <span style="color: #008080; font-style: italic;">///</span>
 <span style="color: #008080; font-style: italic;">/// Description of AppStarter</span>
 <span style="color: #008080; font-style: italic;">///</span>
 <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> AppStarter
 <span style="color: #000000;">&#123;</span>
  Process proc <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
  <span style="color: #0600FF;">public</span> AppStarter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   proc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Process<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> startFirefox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #0600FF;">try</span> <span style="color: #000000;">&#123;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">FileName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;./Firefox/firefox.exe&quot;</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">Arguments</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;-profile ./_profiles/firefox&quot;</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">WindowStyle</span> <span style="color: #008000;">=</span> ProcessWindowStyle.<span style="color: #0000FF;">Hidden</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">CreateNoWindow</span> <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #000000;">&#125;</span>
   <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Win32Exception e<span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
    e.<span style="color: #0000FF;">GetBaseException</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> startThunderbird<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   <span style="color: #0600FF;">try</span> <span style="color: #000000;">&#123;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">FileName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;./Thunderbird/thunderbird.exe&quot;</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">Arguments</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;-profile ./_profiles/thunderbird&quot;</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">WindowStyle</span> <span style="color: #008000;">=</span> ProcessWindowStyle.<span style="color: #0000FF;">Hidden</span><span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">CreateNoWindow</span> <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
    proc.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #000000;">&#125;</span>
   <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Win32Exception e<span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
    e.<span style="color: #0000FF;">GetBaseException</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<ul>
<li>Replace Program.ch with the following codes<br />
File: <code>Program.ch</code></li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Windows.Forms</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> PMozilla
<span style="color: #000000;">&#123;</span>
 <span style="color: #008080; font-style: italic;">///</span>
 <span style="color: #008080; font-style: italic;">/// Class with program entry point.</span>
 <span style="color: #008080; font-style: italic;">///</span>
 <span style="color: #0600FF;">internal</span> <span style="color: #0600FF;">sealed</span> <span style="color: #FF0000;">class</span> Program
 <span style="color: #000000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">///</span>
  <span style="color: #008080; font-style: italic;">/// Program entry point.</span>
  <span style="color: #008080; font-style: italic;">///</span>
  <span style="color: #000000;">&#91;</span>STAThread<span style="color: #000000;">&#93;</span>
  <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
   AppStarter ast <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AppStarter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   ast.<span style="color: #0000FF;">startFirefox</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<ul>
<li>Save project</li>
<li>Build project, make sure there&#8217;s no error</li>
<li>Now go to your project debug Directory (ie. PMozilla\bin\Debug)</li>
<li>You should see PMozilla.exe</li>
<li>Copy this file and paste it in your portable firefox directory. Put it outside directory containing firefox.exe</li>
<li>Rename PMozilla.exe to Firefox.exe</li>
<li>Now double click on a new Firefox.exe</li>
<li>A portable Firefox should start.</li>
</ul>
<p>Create another one for Thunderbird</p>
<ul>
<li>Go back to your IDE and open the same project if it&#8217;s closed</li>
<li>Modify Program.ch</li>
<li>Replace ast.startFirefox(); (line 18) to ast.startThunderbird();</li>
<li>Now, Save project</li>
<li>Build project, make sure there&#8217;s no error</li>
<li>Now go to your project debug Directory (ie. PMozilla\bin\Debug)</li>
<li>You should see PMozilla.exe</li>
<li>Copy this file and paste it in your portable thunderbird directory. Put it outside directory containing thunderbird.exe</li>
<li>Rename PMozilla.exe to Thunderbird.exe</li>
<li>Now double click on a new Thunderbird.exe</li>
<li>A portable Thunderbird should start.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2007/09/06/firefox-starter-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
