<?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>Shah Chandon&#039;s Homepage</title>
	<atom:link href="http://skchandon.com/wp/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://skchandon.com/wp</link>
	<description>Coding in VB, PHP, JAVA, C++, C#</description>
	<lastBuildDate>Sun, 29 Apr 2012 04:06:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>SCADA &#8211; Cygnet</title>
		<link>http://skchandon.com/wp/?p=258</link>
		<comments>http://skchandon.com/wp/?p=258#comments</comments>
		<pubDate>Mon, 30 Jan 2012 05:38:59 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=258</guid>
		<description><![CDATA[<p>Well, for the past two years I was working in the SCADA host replacement project of Union Gas and SCADA had became my life and breath during that period. Now that I have moved on to a different field and given my nature of leaving my past work to the past, I wanted to write [...]]]></description>
			<content:encoded><![CDATA[<p>Well, for the past two years I was working in the SCADA host replacement project of Union Gas and SCADA had became my life and breath during that period. Now that I have moved on to a different field and given my nature of leaving my past work to the past, I wanted to write a few words before I forgot what SCADA was all about for me.</p>
<p>I wrote the real-time programs that would allow controlling of remote devices and also wrote programs that performed different calculations at certain points in time. Programming for SCADA Cygnet was nothing like the kind of programming that I had known before. Previously I had worked with procedural programs, declarative programs and while working in my academic research for natural language processing i had worked extensively with Miranda and some Hascal. and yet I found Real-time programming is so much different fundamentally. It was all because of a simple factor, &#8220;time&#8221;. The added dimension &#8220;Time&#8221; was THE fundamental change in real-time programming. The required programs can be written in any procedural language but the programs must be written so that the temporal aspect of the control flow is covered.</p>
<p>And that was what SCADA was to me.</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=258</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Graphics card temparature</title>
		<link>http://skchandon.com/wp/?p=248</link>
		<comments>http://skchandon.com/wp/?p=248#comments</comments>
		<pubDate>Fri, 30 Dec 2011 05:20:04 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[VB]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=248</guid>
		<description><![CDATA[<p>So I bought a new graphcis card. My old one was getting really old and so i thought i&#8217;d get a new generation one.</p> <p>Only problem though my case doesnt have enough fans to keep it cool. so it gets overheated and then the computer automatically shuts it off beyond a certain high temparature.</p> <p>Now [...]]]></description>
			<content:encoded><![CDATA[<p>So I bought a new graphcis card. My old one was getting really old and so i thought i&#8217;d get a new generation one.</p>
<p>Only problem though my case doesnt have enough fans to keep it cool. so it gets overheated and then the computer automatically shuts it off beyond a certain high temparature.</p>
<p>Now this would happen while im in-game or watching a movie or something.</p>
<p>so i thought why dont i write a small program that will sound an alarm at certain specific temp!</p>
<p>All i needed now is to get a hold of my nvidia cards api and read the sensor data..(working in a SCADA project for the past 2 yrs brought me real ease with sensors.. ;)</p>
<p>Finally after i managed to get <strong>nvcpl.dll </strong>api i wrote the following program:</p>
<pre class="brush: vb">

  Dim ti As New ThermalInfo
        Dim monitorNumber As Integer = 0
        Dim result As Int32 = NvCplGetThermalSettings(monitorNumber, ti.coreTemp, ti.ambientTemp, ti.upperLimit)
        If result = 0 Then Throw New Exception(&quot;eek&quot;)
       
        Dim temp_val As Double = CDbl(result)
        If temp_val &gt; 60 Then
           &#039;Beep()
            My.Computer.Audio.Play(&quot;RTWarning.wav&quot;)
         End If
</pre>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=248</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to fix your wordpress admin panel 500 error</title>
		<link>http://skchandon.com/wp/?p=227</link>
		<comments>http://skchandon.com/wp/?p=227#comments</comments>
		<pubDate>Fri, 09 Dec 2011 02:18:23 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[http 500]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=227</guid>
		<description><![CDATA[<p>Well recently i was getting an error in one of my wordpress sites where i could log in to admin panel but could not post or see posts. it would give me a internal server error 500 error.<br /> This was happening because some of the plugins i had were out of date and was [...]]]></description>
			<content:encoded><![CDATA[<p>Well recently i was getting an error in one of my wordpress sites where i could log in to admin panel but could not post or see posts. it would give me a internal server error 500 error.<br />
This was happening because some of the plugins i had were out of date and was causing conflict with actual wordpress content delivery process. so i went into the database and ran the following query:</p>
<pre class="brush: sql">

update `wp_options` set option_value=&#039;a:0:{}&#039; where option_name=&#039;active_plugins&#039;;
</pre>
<p>and then i came back and activated my plugins one by one after updating each.<br />
boom..it worked :)</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=227</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speeding up your windows startup</title>
		<link>http://skchandon.com/wp/?p=238</link>
		<comments>http://skchandon.com/wp/?p=238#comments</comments>
		<pubDate>Sat, 05 Nov 2011 18:42:49 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=238</guid>
		<description><![CDATA[<p>When the windows starts it loads all sorts of programs (msn messenger, skype etc.)<br /> Sometimes it loads a certain program that you dont always need.<br /> I had that same trouble and to fix it i searched the internet and found out that i have to go to system comfiguration>startup<br /> The easiest way [...]]]></description>
			<content:encoded><![CDATA[<p>When the windows starts it loads all sorts of programs (msn messenger, skype etc.)<br />
Sometimes it loads a certain program that you dont always need.<br />
I had that same trouble and to fix it i searched the internet and found out that i have to go to system comfiguration>startup<br />
The easiest way to go there is to type on start>Run</p>
<pre class="brush: c">
msconfig
</pre>
<p><a href="http://skchandon.com/wp/wp-content/uploads/2011/11/msconfig_ss.jpg"><img src="http://skchandon.com/wp/wp-content/uploads/2011/11/msconfig_ss-206x300.jpg" alt="" title="msconfig_ss" width="206" height="300" class="alignnone size-medium wp-image-239" /></a></p>
<p>That opened up the the system configuration dialog.<br />
<a href="http://skchandon.com/wp/wp-content/uploads/2011/11/system_configuration_ss.jpg"><img src="http://skchandon.com/wp/wp-content/uploads/2011/11/system_configuration_ss-300x204.jpg" alt="" title="system_configuration_ss" width="300" height="204" class="alignnone size-medium wp-image-240" /></a></p>
<p>from this dialog I went to the &#8220;Startup&#8221; tab<br />
<a href="http://skchandon.com/wp/wp-content/uploads/2011/11/system_configuration_startup_tab_ss.jpg"><img src="http://skchandon.com/wp/wp-content/uploads/2011/11/system_configuration_startup_tab_ss-300x201.jpg" alt="" title="system_configuration_startup_tab_ss" width="300" height="201" class="alignnone size-medium wp-image-241" /></a></p>
<p>And then I disabled Skype, Babylon and few other not programs that I felt I don&#8217;t need it upon startup. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=238</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fibonacci Number Calculation in O(n) and O(log n) complexity using VB.Net</title>
		<link>http://skchandon.com/wp/?p=216</link>
		<comments>http://skchandon.com/wp/?p=216#comments</comments>
		<pubDate>Sat, 05 Nov 2011 03:15:42 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=216</guid>
		<description><![CDATA[<p>Ok we all know<a title="Fibonacci Number" href="http://en.wikipedia.org/wiki/Fibonacci_number"> fibonacci number </a>calculation is a classical problem in mathmetics and in computer science. I remember back in the university years, in one semester, I did spend a substantial amount of time behind this problem and eventually wrote a Haskell program to solve the problem. But that was more than [...]]]></description>
			<content:encoded><![CDATA[<p>Ok we all know<a title="Fibonacci Number" href="http://en.wikipedia.org/wiki/Fibonacci_number"> fibonacci number </a>calculation is a classical problem in mathmetics and in computer science. I remember back in the university years, in one semester, I did spend a substantial amount of time behind this problem and eventually wrote a Haskell program to solve the problem. But that was more than a decade ago and my memory is never the sharpest :( . Plus I was thinking of doing it in .Net ( a procedural language unlike Haskell)</p>
<p>So I started with the following code .Net Framework 4.0 ( I needed the &#8220;BigInteger&#8221; Data Type):</p>
<pre class="brush: vb">

Imports System.Numerics

Public Class FibCalc
	Public Sub do_calc(ByVal int_pos as BigInteger)
		msgbox(CalcFib(int_pos))
	End Sub

	Public Function calcFib(ByVal int_pos As BigInteger)

		Dim int_res As BigInteger
		If int_pos = 0 Then
			int_res = 0
		ElseIf int_pos = 1 Then
			int_res = 1
		Else
			int_res = calcFib(int_pos - 1) + calcFib(int_pos - 2)
		End If
		Return int_res
	End Function

End Class
</pre>
<p>The only problem of the above apporach is the computational complexity is O(n<sup>2</sup>) or Exponential</p>
<p>so if you were to try doing &#8220;CalcFib(33)&#8221; it would take approximately 10 minutes and if you go to 40 it would not even compute.<br />
I promised to myself that I would make sometime by the end of the current week and I would sit down and explore other algorithms in procedural programming.</p>
<p>But I got really busy with my own work in the SCADA project. As I was trying to solve some critical problem regarding Energy calculation from gas quality for 500 sensors in under 3 &#8211; 4 seconds in O(n) complexity or atleast O(n.Log n), I almost forgot about it.<br />
But then I remembered :)</p>
<p>So then I implemented the Matrix based approach like the following:</p>
<pre class="brush: vb">

Imports System.Numerics

Public Class FibCalc
	Public Sub do_calc(ByVal int_pos as BigInteger)
		msgbox(CalcFib_usingMatrix(int_pos))
	End Sub

	Public Function calcFib_usingMatrix(ByVal int_pos As BigInteger)

		Dim int_res As BigInteger

		Dim sqrt_of_five As Double

		sqrt_of_five = Math.Sqrt(5)

		&#039;the following formula is a matrix based formula extracted from http://en.wikipedia.org/wiki/Fibonacci_number

		int_res = (1 / sqrt_of_five) * Math.Pow(((1 + sqrt_of_five) / 2), int_pos) - (1 / sqrt_of_five) * Math.Pow(((1 - sqrt_of_five) / 2), int_pos)

		Return int_res

	End Function
End Class
</pre>
<p>This was calculating upto 1400th position in 0.3 ms. Overall the complexity of this approach seems to be log n because the Math.pow function is believed to be a log n complexity. But the problem was somewhere else in this case. If I went beyond 1400 then I was getting an error that said &#8220;BigInteger cannot represent Infinity&#8221;.</p>
<p>Therefore I had to look for alternatives and I thought of one based on the original approach. The problem with the original approach was it was making 2 recursive calls at each iteration. Now essentially we are calculating the same result twice allbeit a single iteration later. so if we can store the result in an global array and then at each iteration we checked the global array if it already holds the value then we can reduce the complexity of one recursive call to a constant. At that point the overall complexity becomes linear, O(n)! I modified the original approach so that once a calculation is done for one side of the + operator, the result is stored in a global array. At every iteration even before trying to make a recursive call I am checking if the current position&#8217;s value already exists in the array. if it doesn&#8217;t then only I am making a recursive call.<br />
Finally, the following is the result of the above thought process:</p>
<pre class="brush: vb">

Imports System.Numerics

	Public Class FibCalc

	Dim arr_main_list() As BigInteger

	Public Sub do_calc(ByVal int_pos as BigInteger)

		ReDim arr_main_list(int_pos)

		msgbox(CalcFib(int_pos))

	End Sub

	Public Function calcFib(ByVal int_pos As BigInteger)

		Dim int_res As BigInteger

		Dim int_part1 As BigInteger

		Dim int_part2 As BigInteger

		If int_pos = 0 Then

			int_res = 0

		ElseIf int_pos = 1 Then

			int_res = 1

		ElseIf Me.arr_main_list(int_pos) &gt; 0 Then

			int_res = Me.arr_main_list(int_pos)

		Else

			int_part1 = calcFib(int_pos - 1)

			int_part2 = calcFib(int_pos - 2)

			int_res = int_part1 + int_part2

			Me.arr_main_list(int_pos) = int_res

		End If

		Return int_res

	End Function

End Class
</pre>
<p>As stated the complexity of this approach is LINEAR O(n)<br />
and I was able to compute 3842nd Fibonacci Number in 5 ms (milliseconds). When I tried to compute 3843 I encountered a stack overflow exception (ran outta memory :( )<br />
In any case here is the 3842nd Fibonaccy Number! Enjoy :)</p>
<div style="word-wrap: break-word; font-family: 'courier new', arial">
38109112796685437235412433289521989141198947838742632373659159771632007762665437269778212865333032033492428796066543895710084571803367000030103381077794080349115832269575038444850243383217226145345984205431058212670357362528116255965921204711895740829023891277213225589555710963198536231090574111103947311440206577423534627605911418991726494460711148883397731521984718974699171039876790006819096000607101358407802274608554720402380995958419974965343396467473451657635964540055879601793962997857861653176508506890636774755473239583704088141781907519139959566293464410347841084284636971840477128942833494329919080172834133239027120817101534398467440790519720925976303594910772412019242124110015922438704548304788646635086582912332880077231232960886054123709968198918982274607807598833007562374316018552321
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=216</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>VB.Net &#8211; Passing Multiple Parameters to a thread call without creating a class object</title>
		<link>http://skchandon.com/wp/?p=202</link>
		<comments>http://skchandon.com/wp/?p=202#comments</comments>
		<pubDate>Wed, 19 Oct 2011 23:03:06 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=202</guid>
		<description><![CDATA[<p>Ok, so in most cases when we need to make a threaded call we need to pass multiple parameters to the worker function. In VB.net by default it supports one parameter to be passed. But when we need to pass more than one parameter then we have to do a little trick.</p> Public sub thread_worker(ByVal [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so in most cases when we need to make a threaded call we need to pass multiple parameters to the worker function. In VB.net by default it supports one parameter to be passed. But when we need to pass more than one parameter then we have to do a little trick.</p>
<pre class="brush: vb">
Public sub thread_worker(ByVal empId as int32, ByVal empName as String, ByRef displayPanel as Panel, ByRef log_output as String)

&#039;Create a generic Objects Array
Dim param_obj(4) as Object

param_obj(0) = empId
param_obj(1) = empName
param_obj(2) = displayPanel
param_obj(3) = log_output

dim worker_thread as New Thread(addressOf showEmpInfo);
worker_thread.Start(param_obj);

End Sub

Public Sub showEmpInfo(ByVal param_objx as Object)
Dim empIdx as Int32, empNamex as String, displayPanelx as Panel, log_outputx as String

empIdx = param_obj(0)
empNamex = param_obj(1)
displayPanelx = param_obj(2)
log_outputx = param_obj(3)

dim empLabel as New Label
empLabel.Text = empIdx &amp; &quot; &quot; &amp; empNamex
displayPanelx.controls.add(empLabel)
log_outputx &amp;=&quot; added EmpID: &quot; &amp; &quot; To the Display&quot; &amp;  vbCrLf

End Sub
</pre>
<p>Observe how the Object array is passed as a parameter using ByVal. When the array is populatd it will contain the refereces/address of the objects. So passing it by value actually passes the whole set of the references.<br />
Thus this trick works even for ByRef variables/Reference variables/Pointer Variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=202</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is WordPress and Why do I care?</title>
		<link>http://skchandon.com/wp/?p=190</link>
		<comments>http://skchandon.com/wp/?p=190#comments</comments>
		<pubDate>Sat, 16 Jul 2011 01:08:00 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=190</guid>
		<description><![CDATA[<p>Often small to Mid size companies spend a lot of resources behind designing a website. Spending money behind a web developer, web designer etc. They would have to spend time analyzing your business needs and other such requirements. You would try to explain what you need and when they come back with a half finished product [...]]]></description>
			<content:encoded><![CDATA[<p>Often small to Mid size companies spend a lot of resources behind designing a website. Spending money behind a web developer, web designer etc. They would have to spend time analyzing your business needs and other such requirements. You would try to explain what you need and when they come back with a half finished product you feel like you are in a terrible mess. But since you have alreayd spent a good amount of money and time you feel you should continue with the venture and see it through to the end. Finally you end up with something that looks almost like what you need with a strong dependency on those technology vendors namely the web developer and the web designer. If your business needs are really unique then you may have no way out from that scenario. However, chances are your business needs are not that complicated that warrants a custom built website costing hundreds or thousands of dollars with people maintaining it 24/7. If thats the case, then lucky you. Modern computer technology has brought you the marvel of &#8220;<a title="WordPress" href="http://wordpress.org/" target="_blank">WordPress</a>&#8220;.</p>
<p>In this article I&#8217;ll try to briefly describe the benefits of WordPress.</p>
<p>WordPress allows you to customize your entire website via custom theme options, plugins, custom menu bars etc. You control all of these from an admin panel where you log in using a username password created during wordpress installation. Now once you are inside the admin panel you can make all sorts of changes to your website. You can copy paste your favourite artice from Ms Word and paste it in a blog post then publish it with beautiful press like fonts in your webiste. And to do all these you don&#8217;t even need a webmaster :)<br />
Lets say you didn&#8217;t like the look of your website and wanted a completely different look, you don&#8217;t have to make an appointment with the web designer neither the web developer. With wordpress you can do that almost instantly. Now themes are not just a skin for your website its also a way of organizing content. There are several types of themes such as Magazine, Blog, Portal etc. There are also some themes that works just like a job board or <a title="kijiji" href="http://kijiji.ca/" target="_blank">kijiji</a> (please note kijiji is not made of WordPress, but there are kijiji likes themes available)<br />
There are many free themes available and also premium paid ones. (But I found the free themes are more than enough to meet my needs.)<br />
In my HTML version website: http://www.skchandon.com/wp<br />
I have 2 types of content: 1) Static Pages and 2) Blog posts.<br />
Blog posts allow comments to be added by the visitors of your website which you can reply back.<br />
This is perfect for holding a sort of Q/A session for the potential customers of the website. You can start a blog post about a topic and as the visitors to your site starts commenting on them you reply them back.<br />
Also, all wordpress (wp) themes are search engine optimized. This means any word that appears in your website will be visible to search engines.<br />
So if you have many unique visitors to your site then those words would draw higer rank for your website in a particular search engine.<br />
This is a huge benefit as it has catalytic effect on the success of your website. The more visitors you get the more ranks you get. The more ranks you get the more higher your website will appear in a persons search when they are searching for keywords such as (Tax, income tax, return etc.) That means you will get more and more visitors. So if you can keep a steady source of interesting tax topics every once or twice a week and then share them on facebook (which you can do very easily from a wordpress blogpost) then your friends will view your posts easily through your facebook wall.</p>
<p>Now that I have listed the &#8220;good&#8221; of WordPress, let me describe the &#8220;bad&#8221;.<br />
The &#8220;bad&#8221; is spam!<br />
As I mentioned before, when you publish a blog post then the visitors to your website can add comments to the post. Now these visitors can be an actual person or &#8220;bots&#8221; that are designed to publish comments randomly with certain ad words in a website. Often you might have to filter through hundreds of comments to find a comment left by an actual person. This could be real problem. Well worry not. The answer is quite simple, wordpress plugins. what are plugins you may ask? Plugins are simple tools that allow you to control different aspect of your website. For example, in the above case we need to stop comments left by &#8220;bots&#8221; (or automated computer programs). So we install a CAPTCHA(<strong>C</strong>ompletely <strong>A</strong>utomated <strong>P</strong>ublic <strong>T</strong>uring test to tell <strong>C</strong>omputers and <strong>H</strong>umans <strong>A</strong>part) plugin. One good CAPTCHA plugin is: <a title="SI CAPTCHA" href="http://www.642weather.com/weather/scripts-wordpress-captcha.php" target="_blank">SI CAPTCHA</a>. You can either visit their website or search for the plugin in your &#8220;<strong>admin panel&gt;Plugins&gt;Add New</strong>&#8221; section. Once you install that plugin and activate it then all the comment box will contain a small image at the bottom which the user has to decipher and provide correct results. Most &#8220;bots&#8221; can&#8217;t do that and voila you have reduced your spam to almost 0%.</p>
<p>Well there are plenty more I could discuss about WordPress but instead I&#8217;ll leave it upto you. If you have access to your website via FTP then make a backup of your existing web content first. Then <a title="WordPress Download" href="http://wordpress.org/download/" target="_blank">download the latest version of wordpress </a>and then upload it via FTP to your website&#8217;s home directory. Then follow this link to <a title="Install WordPress" href="http://codex.wordpress.org/Installing_WordPress" target="_blank">install WordPress</a> as they have done a much better job than I could have done :)</p>
<p>Once you finish installing don&#8217;t forget to login to the admin panel and install the CAPTCHA plugin or else you will be swamped with spam messages.</p>
<p>So if you want a website that you can manage yourself and it still looks stunning costing you 0 dollars then WordPress may be your answer.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=190</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BMP to ICO converter source code</title>
		<link>http://skchandon.com/wp/?p=185</link>
		<comments>http://skchandon.com/wp/?p=185#comments</comments>
		<pubDate>Thu, 14 Jul 2011 20:24:44 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=185</guid>
		<description><![CDATA[<p>The following vb application has a form called &#8220;form1&#8220;. The form has one &#8220;OpenFileDialog&#8221; called &#8220;OpenFileDialog1&#8221; and a file menu item called: &#8220;ChooseBMPToolStripMenuItem&#8220;. The user clicks on the menu item, selects a BMP file and then clicks OK. The program then creates an ico file in the same location as the bmp file</p> Imports System.IO [...]]]></description>
			<content:encoded><![CDATA[<p>The following vb application has a form called &#8220;<code>form1</code>&#8220;. The form has one &#8220;<code>OpenFileDialog</code>&#8221; called &#8220;<code>OpenFileDialog1</code>&#8221; and a file menu item called: &#8220;<code>ChooseBMPToolStripMenuItem</code>&#8220;. The user clicks on the menu item, selects a BMP file and then clicks OK. The program then creates an ico file in the same location as the bmp file</p>
<pre class="brush: vb">
Imports System.IO
Public Class Form1

    Public Sub bmp2ico(ByVal str_source_path As String)
        Dim my_bmp As New Bitmap(str_source_path)
        Dim p As IntPtr

        p = my_bmp.GetHicon
        Dim my_icon As Icon
        my_icon = Icon.FromHandle(p)
        Dim str_dest_path
        str_dest_path = Mid(str_source_path, 1, InStrRev(str_source_path, &quot;.&quot;))
        str_dest_path &amp;amp;amp;= &quot;ico&quot;
        Dim fs As FileStream
        fs = New FileStream(str_dest_path, FileMode.OpenOrCreate)
        my_icon.Save(fs)
        fs.Close()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        bmp2ico(OpenFileDialog1.FileName)
    End Sub

    Private Sub ChooseBMPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChooseBMPToolStripMenuItem.Click
        OpenFileDialog1.FileName = &quot;&quot;
        OpenFileDialog1.Filter = &quot;Windows Bitmap file(*.bmp)|*.bmp&quot;
        OpenFileDialog1.ShowDialog()
    End Sub
End Class
</pre>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=185</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running a dos command from a VB.net application without a window</title>
		<link>http://skchandon.com/wp/?p=148</link>
		<comments>http://skchandon.com/wp/?p=148#comments</comments>
		<pubDate>Wed, 13 Jul 2011 18:07:50 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=148</guid>
		<description><![CDATA[<p>The following code demonstrates how to run an external command line program an not show an window:</p> Dim psi As New ProcessStartInfo(global_str_svn_path, &#34; update &#34; &#38;amp; obj_current_row.Cells(0).Value) Dim ws As Process Dim str_output As String psi.RedirectStandardOutput = True psi.WindowStyle = ProcessWindowStyle.Hidden psi.UseShellExecute = False psi.CreateNoWindow = True ws = Process.Start(psi) While Not ws.StandardOutput.EndOfStream Try text.text [...]]]></description>
			<content:encoded><![CDATA[<p>The following code demonstrates how to run an external command line program an not show an window:</p>
<pre class="brush: vb">

Dim psi As New ProcessStartInfo(global_str_svn_path, &quot; update &quot; &amp;amp; obj_current_row.Cells(0).Value)
Dim ws As Process
Dim str_output As String
psi.RedirectStandardOutput = True
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
psi.CreateNoWindow = True
ws = Process.Start(psi)
While Not ws.StandardOutput.EndOfStream
Try
text.text &amp;amp;= ws.StandardOutput.ReadLine.ToString
Catch ex As Exception
MsgBox(&quot;error: &quot; &amp;amp; ex.Message)
End Try
End While
ws.WaitForExit()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=148</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running an External program from a c# application</title>
		<link>http://skchandon.com/wp/?p=105</link>
		<comments>http://skchandon.com/wp/?p=105#comments</comments>
		<pubDate>Mon, 04 Jul 2011 02:33:43 +0000</pubDate>
		<dc:creator>skchandon</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://skchandon.com/wp/?p=105</guid>
		<description><![CDATA[<p>To pipe the command line output when running an external program, we can do the following in a c# program:</p> using System; using System.Diagnostics; using System.IO; class ExternalCMDExecOutput { static void Main() { // // Setup the process with the ProcessStartInfo class. // ProcessStartInfo start = new ProcessStartInfo(); start.FileName = @&#34;C:\oyurcutsom.exe&#34;; // Specify exe name. [...]]]></description>
			<content:encoded><![CDATA[<p>To pipe the command line output when running an external program, we can do the following in a c# program:</p>
<pre class="brush: c#">
using System;
using System.Diagnostics;
using System.IO;

class ExternalCMDExecOutput
{
    static void Main()
    {
	//
	// Setup the process with the ProcessStartInfo class.
	//
	ProcessStartInfo start = new ProcessStartInfo();
	start.FileName = @&quot;C:\oyurcutsom.exe&quot;; // Specify exe name.
	start.UseShellExecute = false;
	start.RedirectStandardOutput = true;
	//
	// Start the process.
	//
	using (Process process = Process.Start(start))
	{
	    //
	    // Read all text from the process using StreamReader.
	    //
	    using (StreamReader reader = process.StandardOutput)
	    {
			string result = reader.ReadToEnd();
			Console.Write(result);

	    }//(ENDOF) using (StreamReader reader ..)

	}//(ENDOF)using (Process process ..)

    }//(ENDOF)static void Main()

}//(ENDOF)class Program&lt;/pre&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://skchandon.com/wp/?feed=rss2&#038;p=105</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

