<?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>IBlog</title>
	<atom:link href="http://blog.objectpattern.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.objectpattern.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 17 Apr 2010 18:49:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Question your guesses and assumptions</title>
		<link>http://blog.objectpattern.com/random-thoughts/question-your-guesses-and-assumptions/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=question-your-guesses-and-assumptions</link>
		<comments>http://blog.objectpattern.com/random-thoughts/question-your-guesses-and-assumptions/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 18:49:03 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[Random thoughts]]></category>

		<guid isPermaLink="false">http://blog.objectpattern.com/random-thoughts/question-your-guesses-and-assumptions/</guid>
		<description><![CDATA[It’s fare to guess or assume, in fact it helps moving forward in at least one direction, and is inevitable many a times. But started believing that a guess or assumption is truth, can be really harmful. Eventually questioning guesses and assumptions is important, and that also helps being open for multiple perspectives.
]]></description>
			<content:encoded><![CDATA[<p>It’s fare to guess or assume, in fact it helps moving forward in at least one direction, and is inevitable many a times. But started believing that a guess or assumption is truth, can be really harmful. Eventually questioning guesses and assumptions is important, and that also helps being open for multiple perspectives.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/random-thoughts/question-your-guesses-and-assumptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ignorance is not bliss. EventWaitHandle.OpenExisting throws WaitHandleCannotBeOpenedException</title>
		<link>http://blog.objectpattern.com/dot-net/ignorance-is-not-bliss-eventwaithandle-openexisting-throws-waithandlecannotbeopenedexception/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ignorance-is-not-bliss-eventwaithandle-openexisting-throws-waithandlecannotbeopenedexception</link>
		<comments>http://blog.objectpattern.com/dot-net/ignorance-is-not-bliss-eventwaithandle-openexisting-throws-waithandlecannotbeopenedexception/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 06:36:25 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Windows Plateform]]></category>

		<guid isPermaLink="false">http://blog.objectpattern.com/uncategorized/ignorance-is-not-bliss-eventwaithandle-openexisting-throws-waithandlecannotbeopenedexception/</guid>
		<description><![CDATA[My development computer got upgraded to Windows 7, Windows 7 is good experience.
For one of our client, I needed to setup mechanics such that admin users should be able to initiate a process in Windows Service using GDI based .NET application. We had also developed the windows service in .NET. As both of them are [...]]]></description>
			<content:encoded><![CDATA[<p>My development computer got upgraded to Windows 7, Windows 7 is good experience.</p>
<p>For one of our client, I needed to setup mechanics such that admin users should be able to initiate a process in Windows Service using GDI based .NET application. We had also developed the windows service in .NET. As both of them are .NET applications, there are more than one ways to IPC between them. As in this case there was only need to give signal to the service, I choose to do it through <a href="http://msdn.microsoft.com/en-us/library/ms686915(VS.85).aspx">Windows Event</a>. .NET BCL provides wrapper around Win32 functions to do this through type named <a href="http://msdn.microsoft.com/en-us/library/system.threading.eventwaithandle.aspx">EventWaitHandle</a>.</p>
<p>I completed the code like I used to do in my old days, and tried the first use of it. On call to OpenExisting, client application failed with exception &#8220;No handle of the given name exists”. My first thought was that this could be because of UAC, but in that case it should say something like access violation. I tried running application in Windows 2003 Server and it worked perfectly. I decided to check with Google and documentation. I found <a href="http://social.msdn.microsoft.com/Forums/en/clr/thread/91810489-d932-4e4f-bbb7-4a5f02c39cf9">this</a>, which gave me a relieving thought &#8211; “I’m not the only one in this world!” <img src='http://blog.objectpattern.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>After some time I landed to <a href="http://msdn.microsoft.com/en-us/library/aa382954(VS.85).aspx">msdn</a> page for namespaces of kernel objects, which indicates that:</p>
<blockquote><p><em>For processes started under a client session, the system uses the session namespace by default. However, these processes can use the global namespace by prepending the &#8220;Global\&#8221; prefix to the object name</em></p></blockquote>
<p>changed my client code to have name prefixed with “Global\”, and everything started behaving the way I wanted it to in Windows 7 as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/ignorance-is-not-bliss-eventwaithandle-openexisting-throws-waithandlecannotbeopenedexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending code readability by extension methods</title>
		<link>http://blog.objectpattern.com/dot-net/extending-code-readability-by-extension-methods/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=extending-code-readability-by-extension-methods</link>
		<comments>http://blog.objectpattern.com/dot-net/extending-code-readability-by-extension-methods/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 05:40:56 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.objectpattern.com/?p=50</guid>
		<description><![CDATA[If you haven’t noticed, note that extension methods can also be called on null objects. Meaning, there can be extension method which checks whether an object is null or not. So, 
public void Operate(InputType inputObject)
{
    if (null != inputObject)
    {
        . . [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven’t noticed, note that extension methods can also be called on null objects. Meaning, there can be extension method which checks whether an object is null or not. So, </p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> Operate(InputType inputObject)
{
    <span class="kwrd">if</span> (<span class="kwrd">null</span> != inputObject)
    {
        . . .
    }
} 

<span class="kwrd">public</span> <span class="kwrd">void</span> Operate(InputType inputObject)
{
    <span class="kwrd">if</span> (<span class="kwrd">null</span> == inputObject)
    {
        . . .
    }
} </pre>
<pre class="csharpcode">&nbsp;</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Can be replaced by</p>
<pre class="csharpcode"><span class="kwrd"></span>&nbsp;</pre>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> Operate(InputType inputObject)
{
    <span class="kwrd">if</span> (inputObject.IsNotNull())
    {
        . . .
    }
} 

<span class="kwrd">public</span> <span class="kwrd">void</span> Operate(InputType inputObject)
{
    <span class="kwrd">if</span> (inputObject.IsNull())
    {
        . . .
    }
} </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/extending-code-readability-by-extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending email message having embedded image (.NET)</title>
		<link>http://blog.objectpattern.com/dot-net/sending-email-message-having-embedded-image-net/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sending-email-message-having-embedded-image-net</link>
		<comments>http://blog.objectpattern.com/dot-net/sending-email-message-having-embedded-image-net/#comments</comments>
		<pubDate>Fri, 15 May 2009 05:16:25 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">/post/Sending-email-message-having-embedded-image-(NET).aspx</guid>
		<description><![CDATA[Does your .net application send email messages? Does it send formatted email messages? I think applications should always send formatted email messages instead of text only. (Are asking why? Simple, formatted messages are much more capable, presentable, &#8230;).
Counter argument: Some user uses email client that are not capable to show HTML messages. Or someone is [...]]]></description>
			<content:encoded><![CDATA[<p>Does your .net application send email messages? Does it send formatted email messages? I think applications should always send formatted email messages instead of text only. (Are asking why? Simple, formatted messages are much more capable, presentable, &#8230;).</p>
<p>Counter argument: Some user uses email client that are not capable to show HTML messages. Or someone is doing it for security purpose. Okay, I agree, then send both the views; text view as well as HTML view. Using .NET, one can send multi view email messages, depending on email client settings and/or capability, client is expected to pick the right view and shows that to the user.</p>
<p>Next question is, say we have decided to send email in html and text view, can we send images and style sheets embedded with email? Answers is yes. Here is how one can send multi-part email message using .net libraries that has embedded image.</p>
<p>Here goes the first step, create MailMessage object and setup that with appropriate values</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.3%; font-family: consolas, 'Courier New', courier, monospace; height: 60px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   1:</span> var from = <span style="color: #0000ff">new</span> MailAddress(<span style="color: #006080">"admin@objectpattern.com"</span>, <span style="color: #006080">"Himanshu"</span>);</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   2:</span> var to = <span style="color: #0000ff">new</span> MailAddress(<span style="color: #006080">"himanshu@objectpattern.net"</span>);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   3:</span> var message = <span style="color: #0000ff">new</span> MailMessage(from, to) { Subject = <span style="color: #006080">"Hi from ObjectPattern"</span>};</pre>
</div>
</div>
<p>next step changes. As we want to have two views &#8211; text and html, we will have to create email body differently.</p>
<p>in these lines of code, there are certain important points</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.59%; font-family: consolas, 'Courier New', courier, monospace; height: 281px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   1:</span> <span style="color: #008000">//creating text view</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   2:</span> var textViewContent = <span style="color: #006080">"Test content for text view"</span>;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   3:</span> var textView = AlternateView.CreateAlternateViewFromString(textViewContent, Encoding.UTF8,</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   4:</span>                                                            MediaTypeNames.Text.Plain);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   5:</span> <span style="color: #008000">//creating html view </span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   6:</span> var htmlViewContent = <span style="color: #006080">"

Html content containing image logo

Thanks,
ObjectPattern
<img src="cid:logo.png" alt="logo" />"</span>;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   7:</span> var htmlView = AlternateView.CreateAlternateViewFromString(htmlViewContent, Encoding.UTF8,</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   8:</span>                                                            MediaTypeNames.Text.Html);</pre>
</div>
</div>
<p>that I would like to bring in to your notice.</p>
<ul>
<li>Notice that we are not assigning Body property of MailMessage type</li>
<li>While creating view, we are specifying media type name as either plain text or html text, it can also be rich text.</li>
<li>We have created an img tag that referring to source as &#8216;cid:logo.png&#8217;</li>
</ul>
<p>okay now how we will embed image into email message? That&#8217;s easy as well:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.66%; font-family: consolas, 'Courier New', courier, monospace; height: 76px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   1:</span> var logo = <span style="color: #0000ff">new</span> LinkedResource(<span style="color: #006080">"images/logo.png"</span>, MediaTypeNames.Image.Jpeg) {ContentId = <span style="color: #006080">"logo.png"</span>};</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   2:</span> htmlView.LinkedResources.Add(logo);</pre>
</div>
</div>
<p>here in first line, first parameter of constructor (&#8221;image/logo.png&#8221; text) specifies the path of the image file. One can also supply image content as stream if its not coming directly from the file. Now remember, in above section, we had specified the src attribute of img tag, that should match with content id. Else image will not be shown correctly in email client. Also notice that we are adding this image to html view.</p>
<p>We are almost done now. All we need to do now is to add views to message object and sending using SMTP client.</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 99.11%; font-family: consolas, 'Courier New', courier, monospace; height: 58px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   1:</span> message.AlternateViews.Add(textView);</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   2:</span> message.AlternateViews.Add(htmlView);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060">   3:</span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/sending-email-message-having-embedded-image-net/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Changing version of .net framework dependency for setup and deployment project in visual studio 2008</title>
		<link>http://blog.objectpattern.com/dot-net/changing-version-of-net-framework-dependency-for-setup-and-deployment-project-in-visual-studio-2008/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=changing-version-of-net-framework-dependency-for-setup-and-deployment-project-in-visual-studio-2008</link>
		<comments>http://blog.objectpattern.com/dot-net/changing-version-of-net-framework-dependency-for-setup-and-deployment-project-in-visual-studio-2008/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 15:50:40 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[VS.NET]]></category>

		<guid isPermaLink="false">/post/Changing-version-of-net-framework-dependency-for-setup-and-deployment-project-in-visual-studio-2008.aspx</guid>
		<description><![CDATA[Its easy to do, but not obvious to locate, at least to me. It took a while for me to find, so I thought let&#8217;s log it, in case if I need it in future, or someone else might need it. I need to create setup that depends on .NET framework 2.0. instead of 3.5 [...]]]></description>
			<content:encoded><![CDATA[<p>Its easy to do, but not obvious to locate, at least to me. It took a while for me to find, so I thought let&#8217;s log it, in case if I need it in future, or someone else might need it. I need to create setup that depends on .NET framework 2.0. instead of 3.5 which is default in VS.NET 2008.</p>
<p>After creating setup and deployment project, double click on dependency of .net framework in solution explorer:</p>
<p><img class="alignnone size-full wp-image-54" title="doubleClickDependency" src="http://blog.objectpattern.com/wp-content/uploads/2009/01/doubleClickDependency.png" alt="doubleClickDependency" width="304" height="117" /></p>
<p>Now, you should be able to see launch condition for .net framework in <em>&#8220;Launch Conditions&#8221; </em>tab. Until you double click for the first time, node do not appear in launch conditions. And that&#8217;s where I wasted some hours:</p>
<p><img class="alignnone size-full wp-image-55" title="lauch condition" src="http://blog.objectpattern.com/wp-content/uploads/2009/01/lauch-condition.png" alt="lauch condition" width="248" height="107" /></p>
<p>Select the node and see the property window, where you will find the answer of the question:</p>
<p><img class="alignnone size-full wp-image-56" title="version" src="http://blog.objectpattern.com/wp-content/uploads/2009/01/version.png" alt="version" width="562" height="250" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/changing-version-of-net-framework-dependency-for-setup-and-deployment-project-in-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knowing memory usage from Compact Framework application</title>
		<link>http://blog.objectpattern.com/compact-framework/knowing-memory-usage-from-compact-framework-application/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=knowing-memory-usage-from-compact-framework-application</link>
		<comments>http://blog.objectpattern.com/compact-framework/knowing-memory-usage-from-compact-framework-application/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 18:50:38 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[Compact Framework]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Plateform]]></category>

		<guid isPermaLink="false">/post/Knowing-memory-usage-from-Compact-Framework-application.aspx</guid>
		<description><![CDATA[For any handheld device application, memory usage is an important element to observer. .NET Compact framework have very less code that gives information about physical or virtual memory. But using native libraries &#8211; by doing pInvoke, one can retrieve memory usage statistics.
There can be more than one level of report that can be captured. Today, [...]]]></description>
			<content:encoded><![CDATA[<p>For any handheld device application, memory usage is an important element to observer. .NET Compact framework have very less code that gives information about physical or virtual memory. But using native libraries &#8211; by doing pInvoke, one can retrieve memory usage statistics.</p>
<p>There can be more than one level of report that can be captured. Today, lets start with summary. GlobalMemoryStatus function in coredll can help identifying how much total physical memory available in the device and how much of it is free. Same way, how much of virtual memory available to process and how much of it is free.</p>
<p>Lets see how can we use GlobalMemoryStatus. We will have to define a class which will be passed to function and will be filled by GlobalMemoryStatus function. Layout of it is defined as structure by MS team, but its alright to use class here. By having it as class, we will be able to write default constructor unlike structure in C#.</p>
<pre class="csharpcode">    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    <span class="kwrd">internal</span> <span class="kwrd">class</span> MemoryStatus
    {
        <span class="kwrd">public</span> <span class="kwrd">uint</span> dwLength;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> dwMemoryLoad;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullTotalPhys;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullAvailPhys;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullTotalPageFile;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullAvailPageFile;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullTotalVirtual;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullAvailVirtual;
        <span class="kwrd">public</span> <span class="kwrd">uint</span> ullAvailExtendedVirtual;
        <span class="kwrd">public</span> MemoryStatus()
        {
            <span class="kwrd">this</span>.dwLength = (<span class="kwrd">uint</span>)Marshal.SizeOf(<span class="kwrd">typeof</span>(MemoryStatus));
        }
    }
</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Now, lets define extern method for GlobalMemoryStatus</p>
<pre class="csharpcode">        [<span class="kwrd">return</span>: MarshalAs(UnmanagedType.Bool)]
        [DllImport(<span class="str">"coredll.dll"</span>, CharSet = CharSet.Auto, SetLastError = <span class="kwrd">true</span>, EntryPoint = <span class="str">"GlobalMemoryStatus"</span>)]
        <span class="kwrd">static</span> <span class="kwrd">extern</span> <span class="kwrd">bool</span> GlobalMemoryStatusWinCE([In, Out] MemoryStatus lpBuffer);
</pre>
<p>And here is how we can call the method</p>
<pre class="csharpcode">    MemoryStatus internalReport = <span class="kwrd">new</span> MemoryStatus();
    <span class="kwrd">if</span> (GlobalMemoryStatusWinCE(internalReport))</pre>
<pre class="csharpcode">
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/compact-framework/knowing-memory-usage-from-compact-framework-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Navigate and injecting C# code using visual studio macro</title>
		<link>http://blog.objectpattern.com/dot-net/navigate-and-injecting-c-code-using-visual-studio-macro/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=navigate-and-injecting-c-code-using-visual-studio-macro</link>
		<comments>http://blog.objectpattern.com/dot-net/navigate-and-injecting-c-code-using-visual-studio-macro/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 19:32:00 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RoboCoding]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[VS.NET]]></category>

		<guid isPermaLink="false">/post/Navigate-and-injecting-C-code-using-visual-studio-macro.aspx</guid>
		<description><![CDATA[Visual studio macros are great, probably I will write this in all posts that I write for macros  . Sometime back, I need to change a fairly big CF.NET application such a way that it will log a line on each function entry and on function exit. We were tracing for cause of intermittently [...]]]></description>
			<content:encoded><![CDATA[<p>Visual studio macros are great, probably I will write this in all posts that I write for macros <img src='http://blog.objectpattern.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Sometime back, I need to change a fairly big CF.NET application such a way that it will log a line on each function entry and on function exit. We were tracing for cause of intermittently occurring GWES.EXE error, and we were tracing it from multiple directions. The error code of GWES was 0xC0000005, which means someone was trying to access something, which was never allocated or is being accessed after releasing it. Application was multi-threaded, and hence it was difficult to understand which thread will do what at what time.</p>
<p>Moving back to original point, we wanted to log entry and exit of each functions. There can be more then one way to do that, but we have selected to change each functions. And to change each functions I have selected to use developer named <em>&#8220;VS.NET macro&#8221;.</em></p>
<p>From macro it is possible to navigate through solution and projects. So macro first needs to find out all class types from a project, and then for each class, iterate through its member and find out functions that has body. If function has body, inject the code that logs line on function entry and exit.</p>
<p>It was easy to find function entry, but there can be many way function ends, like exception is being thrown, or based of some condition it may execute &#8220;return&#8221;, or body of the function is ended and hence return. To accommodate such cases, we decide to use &#8220;<em>using statement&#8221; </em>of C#.</p>
<p>All right, enough of the background, have look at Macro code <a title="VS.NET Macro" href="http://download.objectpattern.com/LoggingInjection-VS8Macro.vb" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/navigate-and-injecting-c-code-using-visual-studio-macro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenID, myOpenID Rocks!</title>
		<link>http://blog.objectpattern.com/announcements/openid-myopenid-rocks/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openid-myopenid-rocks</link>
		<comments>http://blog.objectpattern.com/announcements/openid-myopenid-rocks/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 06:37:45 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[announcements]]></category>
		<category><![CDATA[openID]]></category>

		<guid isPermaLink="false">/post/OpenID2c-myOpenID-Rocks!.aspx</guid>
		<description><![CDATA[I have been using openID from last 5-6 months as and when I got chance to use it. It&#8217;s getting popular more and more now a days. I see more and more sites supporting it. When first time I learned about it, first thing that came to my mind was to support openID login for [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using openID from last 5-6 months as and when I got chance to use it. It&#8217;s getting popular more and more now a days. I see more and more sites supporting it. When first time I learned about it, first thing that came to my mind was to support openID login for my site. And second thing that came to my mind was, MS passport got competition <img src='http://blog.objectpattern.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .&#160; I haven&#8217;t seen passport authentication much popular apart from Microsoft sites.</p>
<p>As I didn&#8217;t had anything to secure on my site. So far I haven&#8217;t actively started working on to support openID login. It also make sense to have user ids for features like customization, but my site is not supporting that either. I would like to support openID authentication as soon as I finish coding with site-spaces that supports customization and security. Mainly when I need user authentication.</p>
<p>On root (<a href="http://root.objectpattern.com">http://root.objectpattern.com</a>) page, that is like dashboard, I&#8217;m planning to have UI that supports customization/personalization. And once I finish coding Media Gallery, I will need authorization their for different spaces/albums of it, yeah some media will be private to my family and friends. I have done some initial tests using DotNetOpenID (<a title="http://code.google.com/p/dotnetopenid/" href="http://code.google.com/p/dotnetopenid/">http://code.google.com/p/dotnetopenid/</a>). But that library didn&#8217;t worked well on GoDaddy hosting, because of trust level that GoDaddy Deluxe hosting gets. Haven&#8217;t done much research on that to fix it some how.</p>
<p>Also did some initial tests with myOpenId (<a href="http://myopenid.com">http://myopenid.com</a>) to setup such that I/someone can have openId as http://openid.objectpattern.com/<username>. Actually, it wasn&#8217;t that difficult to do. I have my id ready, as <a href="http://openid.objectpattern.com/himanshu">http://openid.objectpattern.com/himanshu</a> I liked myOpenID, it allows to have certificate sign on. </p>
<p>Anyway, I&#8217;m posting this to let you know a) openID Rocks <img src='http://blog.objectpattern.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  b) I&#8217;m planning to be openID consumer, c) setup with help of myOpenId is ready to have openID as openid.objectpattern.com/*.</p>
<p>By the way, did I told you what is openID? Oh, never mind just take a look at it&#8217;s official site (<a href="http://www.openid.net">http://www.openid.net</a>) if you don&#8217;t know what is openID and after that if you have any further queries about it, send me email or comment your query against this post, and I will try answering them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/announcements/openid-myopenid-rocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paging of SQL Server records</title>
		<link>http://blog.objectpattern.com/dot-net/paging-of-sql-server-records/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=paging-of-sql-server-records</link>
		<comments>http://blog.objectpattern.com/dot-net/paging-of-sql-server-records/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 06:29:41 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Sql Server 2005]]></category>

		<guid isPermaLink="false">/post/Paging-of-SQL-Server-records.aspx</guid>
		<description><![CDATA[In one of my ASP.NET, SQL Server project, we were expected to provide paging in the ASP.NET GridView. Microsoft&#8217;s very common sample will do this using Dataset filled with all records. If someone is doing GridView paging, s/he is doing it not waste server&#8217;s or client&#8217;s precious resources, Isn&#8217;t it?
To me, it make more sense [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my ASP.NET, SQL Server project, we were expected to provide paging in the ASP.NET GridView. Microsoft&#8217;s very common sample will do this using Dataset filled with all records. If someone is doing GridView paging, s/he is doing it not waste server&#8217;s or client&#8217;s precious resources, Isn&#8217;t it?</p>
<p>To me, it make more sense to do paging of records being fetched in server memory along with view paging. What if table in question has more then 100,000 (1 lack) records?</p>
<p>Digging a bit further, I found a resource which explains how to do paging of records being sent from stored procedure. But it was expecting to have auto identity as primary key in the table. And we were so fortunate that we couldn&#8217;t have db design such that we can afford to have auto identity primary key, and so that solution to the paging problem. On doing some more finding, we all agreed to a solution that is described below. It&#8217;s not fully optimized, as it do not have any optimization for SQL Server to prepare result sets. But worked for our need in specific project as even in 100,000 records it was working very fast.</p>
<p>In our solution, stored procedure that will fetch records from table and return to caller will needs to have two addition parameters, @RowIndexFrom and @RowIndexTo</p>
<p>Getting customers by page will look like following,</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; height: 242px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> [dbo].[GetCustomersPage]</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">(</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    @RowIndexFrom <span style="color: #0000ff">int</span>,</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    @RowIndexTo <span style="color: #0000ff">int</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">)</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">AS</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">BEGIN</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff">SET</span> NOCOUNT <span style="color: #0000ff">ON</span>;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"> </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff">WITH</span> IndexedCustomers <span style="color: #0000ff">AS</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    (</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        <span style="color: #0000ff">SELECT</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            ROW_NUMBER() <span style="color: #0000ff">OVER</span> (<span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> Id) <span style="color: #0000ff">AS</span> rowIndex,</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            Customers.*</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        <span style="color: #0000ff">FROM</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            Customers</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    )</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff">SELECT</span> * <span style="color: #0000ff">FROM</span> IndexedCustomers <span style="color: #0000ff">WHERE</span> rowIndex <span style="color: #0000ff">BETWEEN</span> @RowIndexFrom <span style="color: #0000ff">AND</span> @RowIndexTo</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"> </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">COUNT</span>(*)</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff">FROM</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        Customers</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">END</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">GO</span></pre>
</div>
</div>
<p> </p>
<p>The stored procedure returns two result set, first will be records for given page (defined by different between @RowIndexFrom and @RowIndexTo parameters). And the second result set will give total number of records for give query. Second result set will help preparing pages list. So, if first page needs to be retrieved of page size 10, parameter values should be 1 and 10 respectively.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/dot-net/paging-of-sql-server-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a windows shortcut using AutoIt</title>
		<link>http://blog.objectpattern.com/auto-it/creating-a-windows-shortcut-using-autoit/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-a-windows-shortcut-using-autoit</link>
		<comments>http://blog.objectpattern.com/auto-it/creating-a-windows-shortcut-using-autoit/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 06:07:00 +0000</pubDate>
		<dc:creator>Himanshu</dc:creator>
				<category><![CDATA[AutoIt]]></category>
		<category><![CDATA[RoboCoding]]></category>

		<guid isPermaLink="false">/post/Creating-a-windows-shortcut-using-AutoIt.aspx</guid>
		<description><![CDATA[AutoIt library do have function to create windows shortcut, FileCreateShortcut. AutoIt script to create new shortcut of specified target in specified file/folder. Once compiled and created executable, use it in following way. 
Usage: 
shortCut.exe&#160;  [] 
First parameter is required and should be path of file/folder for which to create shortcut 
Second parameter is optional [...]]]></description>
			<content:encoded><![CDATA[<p>AutoIt library do have function to create windows shortcut, FileCreateShortcut. AutoIt script to create new shortcut of specified target in specified file/folder. Once compiled and created executable, use it in following way. </p>
<p>Usage: </p>
<p>shortCut.exe&#160; <File/Folder for which to create shortcut> [<File name and path where to create folder>] </p>
<p>First parameter is required and should be path of file/folder for which to create shortcut </p>
<p>Second parameter is optional and if specified, should be full existing path including shortcut file name. If not specified shortcut will be created in the folder from where executable is run. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">If</span> ($CmdLine[0] < 1) <span style="color: #0000ff">Then</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    MsgBox(16, <span style="color: #006080">"Error"</span>, <span style="color: #006080">"Insufficent parameters. In first parameter, specify for which file, shortcut should be created."</span>) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">Return</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">EndIf</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$shortcutOf = $CmdLine[1] </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">If</span> (<span style="color: #0000ff">Not</span> FileExists($shortcutOf)) <span style="color: #0000ff">Then</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    MsgBox(16, <span style="color: #006080">"Error"</span>, <span style="color: #006080">"File/directory "</span><span style="color: #006080">""</span> &#038; $shortcutOf &#038; <span style="color: #006080">""</span><span style="color: #006080">" do not exists"</span>) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">Return</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">EndIf</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$shortcutPath = @WorkingDir &#038; <span style="color: #006080">"\"</span> &#038; <span style="color: #006080">"Shortcut of "</span> &#038; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$shortcutOf &#038; <span style="color: #006080">".lnk"</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">If</span> ($CmdLine[0] = 2) <span style="color: #0000ff">Then</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $shortcutPath = $CmdLine[2] </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">If</span> (StringLower( StringRight($shortcutPath , 4)) <> <span style="color: #006080">".lnk"</span> ) <span style="color: #0000ff">Then</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        $shortcutPath = $shortcutPath &#038; <span style="color: #006080">".lnk"</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">EndIf</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">EndIf</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$objShell = ObjCreate(<span style="color: #006080">"Wscript.Shell"</span>) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$shortcut = $objShell.CreateShortcut($shortcutPath) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$shortcut.TargetPath = $shortcutOf </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$shortcut.WindowStyle = 1 </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$shortcut.Save()</pre>
</p></div>
</div>
<p>If you want to download script file click <a href="http://download.objectpattern.com/shortCut.au3" target="_blank">here</a> </p>
<p>Let me know if you need any further help in it. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.objectpattern.com/auto-it/creating-a-windows-shortcut-using-autoit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
