<?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 &#187; Windows Plateform</title>
	<atom:link href="http://blog.objectpattern.com/category/windows-plateform/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>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>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>
	</channel>
</rss>
