<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Dhawan : The One</title><subtitle type="html" /><id>http://blogs.msdn.com/dhawan/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/dhawan/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2009-07-10T18:47:00Z</updated><entry><title>When custom EAP authentication dll calls EapPeerInvokeInteractiveUI for wireless LAN 802.1x …</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/11/17/when-custom-eap-authentication-dll-calls-eappeerinvokeinteractiveui-for-wireless-lan-802-1x.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/11/17/when-custom-eap-authentication-dll-calls-eappeerinvokeinteractiveui-for-wireless-lan-802-1x.aspx</id><published>2009-11-17T20:35:00Z</published><updated>2009-11-17T20:35:00Z</updated><content type="html">&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;When custom EAP authentication dll calls EapPeerInvokeInteractiveUI for wireless LAN 802.1x, a dialog box is displayed and a balloon is popped-up on Windows Vista machine. And the developer of the EAP authentication dll, needs to suppress dialog box and balloon.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;The scenario is like - You are using custom EAP authentication dll which call EAPHost EapPeerInvokeInteractiveUI function to display a custom dialog box to the user to gather user's credentials. On Windows Vista, there is an additional dialog box displayed by system to get user consent whether they want to "Enter/select additional log on information" or "Connect to a different network" .&amp;nbsp; Clicking on "Enter/select additional log on information" on the consent dialog, the actual dialog is displayed. You want to suppress this intermediate system consent dialog box and possibly balloon as well. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;There is no way to suppress the dialog and balloon on Windows Vista machine, this is by design. On Windows 7, the dialog box has been eliminated by design but balloon is there when the call to EapPeerInvokeInteractiveUI will be made by EAP dll. This is true for profile based authentication and non-profile based authentication if authentication requires user input.&amp;nbsp; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Nitin Dhawan&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Windows SDK – Microsoft&lt;/FONT&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923830" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="Windows Vista" scheme="http://blogs.msdn.com/dhawan/archive/tags/Windows+Vista/default.aspx" /><category term="Windows7" scheme="http://blogs.msdn.com/dhawan/archive/tags/Windows7/default.aspx" /><category term="EapPeerInvokeInteractiveUI" scheme="http://blogs.msdn.com/dhawan/archive/tags/EapPeerInvokeInteractiveUI/default.aspx" /><category term="EAP" scheme="http://blogs.msdn.com/dhawan/archive/tags/EAP/default.aspx" /></entry><entry><title>Introduction to IMAPI</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/11/17/introduction-to-imapi.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/11/17/introduction-to-imapi.aspx</id><published>2009-11-17T20:35:00Z</published><updated>2009-11-17T20:35:00Z</updated><content type="html">&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;In recent past, I have seen few question coming to me asking, “How do I write data on the CD/DVD disk programmatically?” . During my research, I have good introduction to the interfaces available on Windows for burning CD/DVD programmatically that I want to share with all. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;There are two basic way to burn CD/DVD. One question can come pretty early, How does Windows OS in-built functionality works? On Windows XP onwards ( could not check on Windows 2000 or earlier, probably there is none ) we can burn the disc by dragging the files/folders on to the disc. OS does it with the shell interface &lt;A href="http://msdn.microsoft.com/en-us/library/bb776155(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb776155(VS.85).aspx"&gt;ICDBurn Interface&lt;/A&gt;. If you want to burn the files/folders in your program you can use ICDBurn interface but before calling ICDBurn::Burn Method, you need to copy the files/folders in a specific location called CD Staging Area. Once your application selects the files/folders to be written in the CD/DVD and copied to the CD Staging area, calling ICDBurn::Burn Method will burn the CD/DVD, same as OS and delete the files from that location automatically. CD Staging area can be determined by the application by the information available in MSDN documentation as below -- &lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The &lt;EM&gt;staging area&lt;/EM&gt; has a default location of %userprofile%\Local Settings\Application Data\Microsoft\CD Burning. Its actual path can be retrieved through &lt;A href="http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx"&gt;SHGetFolderPath&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bb762204(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb762204(VS.85).aspx"&gt;SHGetSpecialFolderPath&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bb762180(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb762180(VS.85).aspx"&gt;SHGetFolderLocation&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bb762203(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb762203(VS.85).aspx"&gt;SHGetSpecialFolderLocation&lt;/A&gt;, or &lt;A href="http://msdn.microsoft.com/en-us/library/bb762182(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb762182(VS.85).aspx"&gt;SHGetFolderPathAndSubDir&lt;/A&gt; by using the CSIDL_CDBURN_AREA value.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Other way to burn CD/DVD is using &lt;A href="http://msdn.microsoft.com/en-us/library/aa366450(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa366450(VS.85).aspx"&gt;Image Mastering API&lt;/A&gt; or IMAPI in short. IMAPI comes in two versions &lt;A href="http://msdn.microsoft.com/en-us/library/aa366192(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa366192(VS.85).aspx"&gt;IMAPIv1&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/aa366457(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa366457(VS.85).aspx"&gt;IMAPIv2&lt;/A&gt;. IMAPIv1 is available for application to be used on Windows XP and Windows Server 2003 and IMAPIv2 is available on Windows Vista onwards, in-box. You can also get the IMAPIv2 available on Windows XP and Windows Server 2003 after installing a package, links and information are below-- &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa366457(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa366457(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;What's New&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;IMAPI 2.0 is included in Windows Vista. Enabling the same functionality for Windows XP and Windows Server 2003 requires the installation of the &lt;A href="http://support.microsoft.com/kb/932716" target=_blank mce_href="http://support.microsoft.com/kb/932716"&gt;KB932716&lt;/A&gt; update package. 
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;After installing &lt;/FONT&gt;&lt;A href="http://support.microsoft.com/kb/932716" target=_blank mce_href="http://support.microsoft.com/kb/932716"&gt;&lt;FONT size=3 face=Tahoma&gt;Description of the Image Mastering API v2.0 (IMAPIv2.0) update package that is dated June 26, 2007&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Tahoma&gt; on Windows XP or&amp;nbsp; Windows Server 2003, application can use the interfaces exposed by IMAPIv2. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Note – Before burning any CD/DVD please see through documentation that which filesystem you want the IMAPI interfaces to be written on the disc? There are few options available like ISO9660, Joliet and UDF. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Next, few links to be shared for IMAPIv1 interfaces available. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365379(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365379(VS.85).aspx"&gt;IDiscMaster Interface&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365400(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365400(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IDiscMaster::Open Method&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365403(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365403(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IDiscMaster::RecordDisc Method&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Next, few links to be shared for IMAPIv1 interfaces available.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365380(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365380(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IDiscMaster2 Interface&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365407(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365407(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IDiscRecorder2 Interface&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Also, IMAPIv2 has multisession support and interfaces are available. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Samples- While there are code snippet sample available on MSDN documentations of the interface/method, there are 2 complete sample applications available in Windows SDK for Vista ( onwards ). Sample locations are below after you install Windows SDK on the dev machine ---&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;%program files%\Microsoft SDKs\Windows\v6.0\Samples\WinBase\imapi\imapi2sample&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;%program files%\Microsoft SDKs\Windows\v6.0\Samples\WinBase\storage\IBurn&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;While imapi2sample is native code in C++, IBurn sample is managed in C#. Please refer to the samples for more understandings of the IMAPI, that can give good start if you want to develop a feature/application for CD/DVD burning.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Windows SDK – Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923832" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="IMAPI" scheme="http://blogs.msdn.com/dhawan/archive/tags/IMAPI/default.aspx" /><category term="CD" scheme="http://blogs.msdn.com/dhawan/archive/tags/CD/default.aspx" /><category term="burn" scheme="http://blogs.msdn.com/dhawan/archive/tags/burn/default.aspx" /><category term="DVD" scheme="http://blogs.msdn.com/dhawan/archive/tags/DVD/default.aspx" /><category term="Image Mastering API" scheme="http://blogs.msdn.com/dhawan/archive/tags/Image+Mastering+API/default.aspx" /></entry><entry><title>Send multiple files to FAX in one call</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/11/17/send-multiple-files-to-fax-in-one-call.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/11/17/send-multiple-files-to-fax-in-one-call.aspx</id><published>2009-11-17T20:34:00Z</published><updated>2009-11-17T20:34:00Z</updated><content type="html">&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;There might be a need that an application need to send multiple files to the FAX server in one single call. While &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms686179(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms686179(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IFaxDocument::ConnectedSubmit Method&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Tahoma&gt; allows to send a single file to FAX in one call, &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa359009(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa359009(VS.85).aspx"&gt;&lt;FONT size=3 face=Tahoma&gt;IFaxDocument2::ConnectedSubmit2 Method&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3 face=Tahoma&gt; can be used to send multiple files. The IFaxDocument2::ConnectedSubmit2 Method can be used only on Windows Vista and later versions. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;As in online documentation, the syntax to mention multiple files name/path is as below-- &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;To illustrate &lt;I&gt;plErrorBodyFile&lt;/I&gt;, here is an example: The following list of files is submitted as the value of &lt;B&gt;IFaxDocument2::Bodies&lt;/B&gt;: 
&lt;P&gt;"MyTextFile.txt;AnotherTextFile.txt;MyWordFile.doc". 
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Also in the documentation it is mentioned that the .pdf format is not supported by the interface. So if a file with .pdf is supplied to be sent to the FAX server, method will fail with error 2.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;To understand the usage of the interface/method, you can use “SendFax” sample in Windows SDK for Vista in below path--&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;%program files%\Microsoft SDKs\Windows\v6.0\Samples\NetDs\Fax\SendFax&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;SendFax sample is available in C++, C# and VB.NET languages.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3 face=Tahoma&gt;Windows SDK – Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923829" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="Windows Vista" scheme="http://blogs.msdn.com/dhawan/archive/tags/Windows+Vista/default.aspx" /><category term="FaxComexLib" scheme="http://blogs.msdn.com/dhawan/archive/tags/FaxComexLib/default.aspx" /><category term="FaxDocument" scheme="http://blogs.msdn.com/dhawan/archive/tags/FaxDocument/default.aspx" /></entry><entry><title>Get the MAC address of a machine/device whose IP Address is known</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/10/05/get-the-mac-address-of-a-machine-device-whose-ip-address-is-known.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/10/05/get-the-mac-address-of-a-machine-device-whose-ip-address-is-known.aspx</id><published>2009-10-05T20:54:00Z</published><updated>2009-10-05T20:54:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Sometime you may be in a situation to get the MAC address of a machine/device whose IP Address is known. Conventional way like using NetBios or &lt;A href="http://msdn.microsoft.com/en-us/library/aa365917(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365917(VS.85).aspx"&gt;GetAdaptersInfo&lt;/A&gt; or &lt;A href="http://msdn.microsoft.com/en-us/library/aa365915(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365915(VS.85).aspx"&gt;GetAdaptersAddresses&lt;/A&gt; can give the MAC address of the same machine where the code is running, does not solve the purpose because the machine where the code is executing is not the one for which you have the IP Address and need MAC address. You need API like below -- &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;GetmeMACAddress_IgaveYouIP(&amp;amp;Mac,&amp;amp;IP);&amp;nbsp; , then life will be easy. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;It was clear that ARP protocol will be used for this purpose, but I need to find the programmatic way.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;There is a command “arp” that does it, so definitely it is possible to do that. ( arp –a &amp;lt;IP Address&amp;gt; ) will give the MAC address of the machine/device. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Initially when I searched on Internet to find the answer, there were some manual ways and couple of tools, but I want to program it myself, so not of much use. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Later, going though the documentation of Network functions on MSDN site, &lt;A href="http://msdn.microsoft.com/en-us/library/aa366358(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa366358(VS.85).aspx"&gt;SendARP Function&lt;/A&gt; from IpHelper library, was looking closer. Testing with the sample application available on MSDN page, it works just fine and solve the purpose.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Please read the Remarks section of the API documentation.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Windows SDK – Microsoft&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903358" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="ip" scheme="http://blogs.msdn.com/dhawan/archive/tags/ip/default.aspx" /><category term="Address Resolution Protocol" scheme="http://blogs.msdn.com/dhawan/archive/tags/Address+Resolution+Protocol/default.aspx" /><category term="Physical" scheme="http://blogs.msdn.com/dhawan/archive/tags/Physical/default.aspx" /><category term="ARP" scheme="http://blogs.msdn.com/dhawan/archive/tags/ARP/default.aspx" /><category term="SendARP" scheme="http://blogs.msdn.com/dhawan/archive/tags/SendARP/default.aspx" /><category term="GetAdaptersInfo" scheme="http://blogs.msdn.com/dhawan/archive/tags/GetAdaptersInfo/default.aspx" /><category term="MAC" scheme="http://blogs.msdn.com/dhawan/archive/tags/MAC/default.aspx" /><category term="Address" scheme="http://blogs.msdn.com/dhawan/archive/tags/Address/default.aspx" /><category term="GetAdaptersAddresses" scheme="http://blogs.msdn.com/dhawan/archive/tags/GetAdaptersAddresses/default.aspx" /><category term="IPHelper" scheme="http://blogs.msdn.com/dhawan/archive/tags/IPHelper/default.aspx" /></entry><entry><title>Enable or Disable “Enable write caching on disk” behavior on disk</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/10/05/enable-or-disable-enable-write-caching-on-disk-behavior-on-disk.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/10/05/enable-or-disable-enable-write-caching-on-disk-behavior-on-disk.aspx</id><published>2009-10-05T20:53:00Z</published><updated>2009-10-05T20:53:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Couple of times I got a question to &amp;lt;Enable or Disable “Enable write caching on disk” behavior on disk&amp;gt;, How to do it programmatically on Windows? When I got this question for the first time, it was tough but doing research I was able to solve it and it works well. Every next time, it was easy :)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;In this post, I will not discuss what exactly this feature does and pros and cons of enable/disable it. I will only discuss, How to do it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/EnableorDisableEnablewritecachingondiskb_B749/disk_cache_1.png" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/EnableorDisableEnablewritecachingondiskb_B749/disk_cache_1.png"&gt;&lt;IMG title=disk_cache style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px; BORDER-RIGHT-WIDTH: 0px" height=677 alt=disk_cache src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/EnableorDisableEnablewritecachingondiskb_B749/disk_cache_thumb_1.png" width=389 align=left border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/EnableorDisableEnablewritecachingondiskb_B749/disk_cache_thumb_1.png"&gt;&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;You can do it manually as well.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;#1, Select a volume from Explorer, right click –&amp;gt; Properties&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;#2, Select “Hardware” tab, select disk and click “Properties” button&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;#3, Select “Policies” tab.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;#4, Check/Uncheck to enable/disable “write caching on the disk”&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;To do it programmatically.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;#1, You will need to work with below APIs and control code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx"&gt;&lt;FONT face=Tahoma size=3&gt;CreateFile Function&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx"&gt;&lt;FONT face=Tahoma size=3&gt;DeviceIoControl Function&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa363963(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa363963(VS.85).aspx"&gt;&lt;FONT face=Tahoma size=3&gt;DISK_CACHE_INFORMATION Structure&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365165(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365165(VS.85).aspx"&gt;&lt;FONT face=Tahoma size=3&gt;IOCTL_DISK_GET_CACHE_INFORMATION Control Code&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365187(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa365187(VS.85).aspx"&gt;&lt;FONT face=Tahoma size=3&gt;IOCTL_DISK_SET_CACHE_INFORMATION Control Code&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;The information is actually gets stored in below registry key, I would not recommend to look for the value in the key directly and design your application on that. It may change in future. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=taho size=3&gt;HKLM\SYSTEM\CurrentControlSet\Enum\IDE\Diskxxxxxxxxxxxx\DeviceParameters\Disk&lt;BR&gt;Key : UserWriteCacheSetting&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;where xxxxxxx is manufacturer information.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;The sample will look like below. This is just a test sample and provided only to demonstrate the functionality. You might need to use put more error handling and test the code as you do for regular production environment code. &lt;/FONT&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;//////////////////////SAMPLE CODE &lt;/SPAN&gt;
&lt;SPAN class=rem&gt;///////////////////////////////////////////////////////////&lt;/SPAN&gt;
&lt;SPAN class=preproc&gt;#define&lt;/SPAN&gt; _WIN32_WINNT 0x0503

#include &amp;lt;windows.h&amp;gt;

DISK_CACHE_INFORMATION info;
DISK_CACHE_INFORMATION rinfo;


&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; main(&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt;)
{
    DWORD rr;
    HANDLE hDevice;
    DWORD err;
    DWORD returned;

    hDevice = CreateFile(&lt;SPAN class=str&gt;"\\\\.\\C:"&lt;/SPAN&gt;, &lt;SPAN class=rem&gt;// drive to open&lt;/SPAN&gt;
                GENERIC_READ | GENERIC_WRITE,
                FILE_SHARE_WRITE | FILE_SHARE_READ, 
                &lt;SPAN class=rem&gt;// share mode&lt;/SPAN&gt;
                NULL, &lt;SPAN class=rem&gt;// default security attributes&lt;/SPAN&gt;
                OPEN_EXISTING, &lt;SPAN class=rem&gt;// disposition&lt;/SPAN&gt;
                FILE_ATTRIBUTE_SYSTEM, &lt;SPAN class=rem&gt;// file attributes&lt;/SPAN&gt;
                NULL); &lt;SPAN class=rem&gt;// do not copy file attributes&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;(hDevice==INVALID_HANDLE_VALUE)
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt;;
    }

    rr = DeviceIoControl(hDevice,IOCTL_DISK_GET_CACHE_INFORMATION,NULL,
                        0,(LPVOID)&amp;amp;info,(DWORD)&lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(info),(LPDWORD)&amp;amp;returned,    (LPOVERLAPPED)NULL);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!rr)
    {
        err = GetLastError();
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt;;
    }

    info.WriteCacheEnabled = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;
    info.ReadCacheEnabled = &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;;
    info.DisablePrefetchTransferLength = 1;

    rr = DeviceIoControl(hDevice,IOCTL_DISK_SET_CACHE_INFORMATION,(LPVOID)&amp;amp;info,(DWORD)&lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(info),
                        NULL,0,(LPDWORD)&amp;amp;returned,(LPOVERLAPPED)NULL);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!rr)
    {
        err = GetLastError();
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt;;
    }

    rr = DeviceIoControl(hDevice,IOCTL_DISK_GET_CACHE_INFORMATION,NULL,0,
                        (LPVOID)&amp;amp;rinfo,(DWORD)&lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(rinfo),(LPDWORD)&amp;amp;returned,(LPOVERLAPPED)NULL);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!rr)
    {
        err = GetLastError();
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt;;
    }

    CloseHandle(hDevice);
}
&lt;SPAN class=rem&gt;//////////////////////SAMPLE CODE &lt;/SPAN&gt;
///////////////////////////////////////////////////////////&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.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; }
&lt;/STYLE&gt;
&lt;FONT face=taho size=3&gt;*Note—Not all disks and controllers implements write disk caching, I have not tested the behavior or any such disk yet, so behavior is unknown to me.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903357" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="CreateFile" scheme="http://blogs.msdn.com/dhawan/archive/tags/CreateFile/default.aspx" /><category term="DeviceIoControl" scheme="http://blogs.msdn.com/dhawan/archive/tags/DeviceIoControl/default.aspx" /><category term="IOCTL_DISK_SET_CACHE_INFORMATION" scheme="http://blogs.msdn.com/dhawan/archive/tags/IOCTL_5F00_DISK_5F00_SET_5F00_CACHE_5F00_INFORMATION/default.aspx" /><category term="IOCTL_DISK_GET_CACHE_INFORMATION" scheme="http://blogs.msdn.com/dhawan/archive/tags/IOCTL_5F00_DISK_5F00_GET_5F00_CACHE_5F00_INFORMATION/default.aspx" /><category term="DISK_CACHE_INFORMATION" scheme="http://blogs.msdn.com/dhawan/archive/tags/DISK_5F00_CACHE_5F00_INFORMATION/default.aspx" /></entry><entry><title>Check membership of a group from user’s process access token</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/10/05/check-membership-of-a-group-from-user-s-process-access-token.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/10/05/check-membership-of-a-group-from-user-s-process-access-token.aspx</id><published>2009-10-05T20:52:00Z</published><updated>2009-10-05T20:52:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Question may be, I need to check If the user belong to a particular group or not? There are NetUser* APIs available in NetApi32.lib to list the groups a user belong to a group. You can actually check but then you will need to compare the string of the group you are interested to check and the list returned by the NetApi. Please see the sample available on &lt;A href="http://msdn.microsoft.com/en-us/library/aa370653(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa370653(VS.85).aspx"&gt;NetUserGetGroups Function&lt;/A&gt;. This approach can be acceptable in some scenarios, but may not work in other. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;In a domain environment, there are two domains A and B and have trust relationship in between them. An user of domain A, logged on to a machine in domain B. The application running as domainA\UserA, calls NetUserGetGroups to get the global groups of the user, for any purpose. Generally it should work fine and works fine, I have tested it on many environments, but this approach may fail as well. If the domain where the query should go, has not opened the port ( by firewall ) the API is going to use, then API will not able to get the list of groups for the user. To solve the problem, you need to open the port, which may not be possible because the management of DC on other end not want to do it at all. Now, How to solve it?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;When the user logs on providing credentials, authenticated by the AD on DC successfully, gets the logon token, profile is loaded, desktop is created etc etc. The logon token has the information about the user, for what groups it belong to. When user launched any application, it will be launched by this logon token. So, the information about the groups is already within the process itself. You can check it with a tool called whoami (/all) in Windows directory. If we have any API to read this list then we don’t have to go to network again or use NetAPIs. &lt;A href="http://msdn.microsoft.com/en-us/library/aa446671(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa446671(VS.85).aspx"&gt;GetTokenInformation Function&lt;/A&gt; can be used to list the groups and for other purposes. Is there an API to actually check if the user belong to a particular group? &lt;A href="http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx"&gt;CheckTokenMembership Function&lt;/A&gt; can be used for this purpose. API does not look for the group by its name, but by SID. If we have the name, we can convert to SID and pass to CheckTokenMembership. Demo sample code will look like below--&lt;/FONT&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt;&amp;lt;windows.h&amp;gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt;&amp;lt;Sddl.h&amp;gt;
&lt;FONT color=#0000ff&gt;&lt;SPAN class=preproc&gt;#pragma&lt;/SPAN&gt; comment&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;lib&lt;/FONT&gt;,&lt;SPAN class=str&gt;"Advapi32.lib"&lt;/SPAN&gt;)
&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; main (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; argc, CHAR * argv[]) 
{
BOOL bStatus;
BOOL bIsMember;
SID_NAME_USE sid_name_use;
DWORD dwDomainNameSize;
TCHAR tszDomainName [256];
PSID pSidToCheck;
DWORD cbsid=1024;
LPBYTE pPDC = NULL;
HANDLE hToken;

    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (argc != 2){
        printf(&lt;SPAN class=str&gt;"\nUSAGE: %ls grouptocheck\n\n"&lt;/SPAN&gt;, argv[0]);
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
    }

    bStatus = OpenProcessToken(OpenProcess(GENERIC_ALL, FALSE, GetCurrentProcessId()), GENERIC_ALL, &amp;amp;hToken);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!bStatus){
        printf(&lt;SPAN class=str&gt;"OpenProcessToken failed: %u\n"&lt;/SPAN&gt;, GetLastError());
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
    }

    pSidToCheck = malloc (cbsid );
    dwDomainNameSize = &lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(tszDomainName);
    bStatus = LookupAccountName(
        NULL,       &lt;SPAN class=rem&gt;// address of string for system name&lt;/SPAN&gt;
        argv[1],      &lt;SPAN class=rem&gt;// address of string for account name&lt;/SPAN&gt;
        pSidToCheck,      &lt;SPAN class=rem&gt;// address of security identifier&lt;/SPAN&gt;
        &amp;amp;cbsid,      &lt;SPAN class=rem&gt;// address of size of security identifier&lt;/SPAN&gt;
        tszDomainName,      &lt;SPAN class=rem&gt;// address of string for referenced domain &lt;/SPAN&gt;
        &amp;amp;dwDomainNameSize,      &lt;SPAN class=rem&gt;// address of size of domain string&lt;/SPAN&gt;
        &amp;amp;sid_name_use       &lt;SPAN class=rem&gt;// address of SID-type indicator&lt;/SPAN&gt;
    );

    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!bStatus){
        printf(&lt;SPAN class=str&gt;"LookupAccountName failed: %u\n"&lt;/SPAN&gt;, GetLastError());
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
    }

    bStatus = CheckTokenMembership(&lt;SPAN class=rem&gt;/*hToken*/&lt;/SPAN&gt; NULL, pSidToCheck, &amp;amp;bIsMember);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!bStatus){
        printf(&lt;SPAN class=str&gt;"CheckTokenMembership failed: %u\n"&lt;/SPAN&gt;, GetLastError());
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
    }

    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (bIsMember)
        printf(&lt;SPAN class=str&gt;"The user is a member of the group.\n"&lt;/SPAN&gt;);
    &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
        printf(&lt;SPAN class=str&gt;"The user is NOT a member of the group.\n"&lt;/SPAN&gt;);    
    
    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 0;

}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.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; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903356" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="CheckTokenMembership" scheme="http://blogs.msdn.com/dhawan/archive/tags/CheckTokenMembership/default.aspx" /></entry><entry><title>Troubleshoot thread data race conditions in multithreaded environment: Chess</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/09/28/troubleshoot-thread-data-race-conditions-in-multithreaded-environment-chess.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/09/28/troubleshoot-thread-data-race-conditions-in-multithreaded-environment-chess.aspx</id><published>2009-09-29T01:24:00Z</published><updated>2009-09-29T01:24:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face=taho size=3&gt;Someone pointed me to look at this tool and see if there is any equivalent we have already or not. I looked at it and found it interesting. I have not explored this tool yet, but looks like it will be very helpful in debugging complex multithreaded applications and found the bug in early stages of the software development.This is &lt;/FONT&gt;&lt;A href="http://research.microsoft.com/en-us/projects/chess/" target=_blank mce_href="http://research.microsoft.com/en-us/projects/chess/"&gt;&lt;FONT face=taho size=3&gt;CHESS&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=taho size=3&gt;, new project from Microsoft Research. The initial walkthrough on the pages, Chess can be integrated in Visual Studio environment as well. Chess works both native and managed code. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://research.microsoft.com/en-us/projects/chess/download.aspx" target=_blank mce_href="http://research.microsoft.com/en-us/projects/chess/download.aspx"&gt;CHESS Downloads&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://blogs.msdn.com/chess/" target=_blank mce_href="http://blogs.msdn.com/chess/"&gt;CHESS: Find and Reproduce Concurrency Heisenbugs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://blogs.msdn.com/chess/archive/2009/01/20/the-chess-scheduler-the-key-to-finding-concurrency-bugs.aspx" target=_blank mce_href="http://blogs.msdn.com/chess/archive/2009/01/20/the-chess-scheduler-the-key-to-finding-concurrency-bugs.aspx"&gt;The CHESS scheduler – the key to finding concurrency bugs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Also, installation of Chess provides significant amount of samples and tests to start with.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Explore Chess !!!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=taho size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900490" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="managed" scheme="http://blogs.msdn.com/dhawan/archive/tags/managed/default.aspx" /><category term="multi-threaded" scheme="http://blogs.msdn.com/dhawan/archive/tags/multi-threaded/default.aspx" /><category term="Chess" scheme="http://blogs.msdn.com/dhawan/archive/tags/Chess/default.aspx" /><category term="thread" scheme="http://blogs.msdn.com/dhawan/archive/tags/thread/default.aspx" /><category term="data race condition" scheme="http://blogs.msdn.com/dhawan/archive/tags/data+race+condition/default.aspx" /><category term="native" scheme="http://blogs.msdn.com/dhawan/archive/tags/native/default.aspx" /></entry><entry><title>Slimmest way to call an exported function of unmanaged dll from a managed C# application</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/08/31/slimmest-way-to-call-an-exported-function-of-unmanaged-dll-from-a-managed-c-application.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/08/31/slimmest-way-to-call-an-exported-function-of-unmanaged-dll-from-a-managed-c-application.aspx</id><published>2009-08-31T07:41:00Z</published><updated>2009-08-31T07:41:00Z</updated><content type="html">&lt;P&gt;&lt;FONT size=3&gt;Many times I came to situation that someone don’t know a good way to call an exported function of unmanaged dll from a managed application C# or VB. Person might not have any working knowledge of unmanaged dll, if they are required to create one. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;I am writing this post just to demonstrate, how to create a unm&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;anaged dll and then export a function from it and call that function from the managed C# application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT size=3&gt;Create unmanaged dll to export a function&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;First of all, I create a dll project that exports symbols. I will get the default template project which is ready to export a function, but I will create my own function.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; MyWin32Function()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; 22;&lt;BR&gt;}&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;If the declaration of the function is &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; MyWin32Function(); , then it will not be exported from the dll. You can check it from the dumpbin utility or Dependency Walker tool. How to make function exportable/visible to application? &lt;FONT color=#0000ff&gt;__declspec(dllexport)&lt;/FONT&gt; will be used to mark the function exportable. If the function declaration looks like below -&lt;FONT color=#0000ff&gt;__declspec(dllexport)&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; MyWin32Function(); , Is it exportable? Now if you compile it again and see from dumpbin, you see that the function is exported, but the name of the function is decorated. MyWin32Function will look like ?MyWin32Function@@SoMeChArS. This name decoration is because of name mangling of C++ compiler. It is not possible from the application to call the function with this name, the exported function from dll should be in human readable form, which is convenient, easy to document and easier to use. So, now the problem is, function is exported but with name decoration. We will need to eliminate name decoration so that application can use it easily. &lt;FONT color=#0000ff&gt;extern&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;"C"&lt;/FONT&gt; will be helpful here, asking the C++ compiler to compile as C and no name decoration. Now, function declaration will look like below --&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;FONT color=#0000ff&gt;extern&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;"C" &lt;FONT color=#0000ff&gt;__declspec(dllexport)&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; &lt;FONT color=#000000&gt;MyWin32Function();&lt;/FONT&gt; &lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;The dll is ready to be used with exported MyWin32Function. Now, we need to call it from C# application. &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;FONT size=3&gt;Now, you will need to call a unmanaged function from custom dll from a managed app, C#, need P/Invoke. I have discussed about the P/Invoke in my &lt;A href="http://blogs.msdn.com/dhawan/archive/2009/08/23/platform-invoke.aspx" target=_blank mce_href="http://blogs.msdn.com/dhawan/archive/2009/08/23/platform-invoke.aspx"&gt;previous post&lt;/A&gt;. You can download P/Invoke Interop Assistant tool. You will need to create the signature of MyWin32Function(). I will use the declaration of my function in the tool and create a signature.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Slimmestwaytocallanexportedfunctionofunm_14731/pinvoke_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Slimmestwaytocallanexportedfunctionofunm_14731/pinvoke_2.jpg"&gt;&lt;IMG title=pinvoke style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=243 alt=pinvoke src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Slimmestwaytocallanexportedfunctionofunm_14731/pinvoke_thumb.jpg" width=705 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Slimmestwaytocallanexportedfunctionofunm_14731/pinvoke_thumb.jpg"&gt;&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;For simplicity, I will use the code in same class. Copy below code to C# application.&lt;/FONT&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;/// Return Type: int&lt;/SPAN&gt;
[System.Runtime.InteropServices.DllImportAttribute(&lt;SPAN class=str&gt;"&amp;lt;Unknown&amp;gt;"&lt;/SPAN&gt;, EntryPoint = &lt;SPAN class=str&gt;"MyWin32Function"&lt;/SPAN&gt;)]
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; MyWin32Function();&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.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; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;FONT size=3&gt;I will need to change the dll name to my dll name rather than &lt;SPAN class=str&gt;&amp;lt;Unknown&amp;gt;&lt;/SPAN&gt;.&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;/// Return Type: int&lt;/SPAN&gt;
[System.Runtime.InteropServices.DllImportAttribute(&lt;SPAN class=str&gt;"MyWin32Dll.dll"&lt;/SPAN&gt;, EntryPoint = &lt;SPAN class=str&gt;"MyWin32Function"&lt;/SPAN&gt;)]
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; MyWin32Function();&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.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; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;FONT size=3&gt;Now, You can call this function from C# application below-&lt;/FONT&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; a = 0;
a = MyWin32Function();
Console.WriteLine(&lt;SPAN class=str&gt;"returned from dll {0}"&lt;/SPAN&gt;,a);&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.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; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;FONT size=3&gt;To pass parameters from managed application to unmanaged dll function, you will need to work on marshalling the data structures.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9889228" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="unmanaged" scheme="http://blogs.msdn.com/dhawan/archive/tags/unmanaged/default.aspx" /><category term="managed" scheme="http://blogs.msdn.com/dhawan/archive/tags/managed/default.aspx" /><category term="P/Invoke" scheme="http://blogs.msdn.com/dhawan/archive/tags/P_2F00_Invoke/default.aspx" /><category term="dll" scheme="http://blogs.msdn.com/dhawan/archive/tags/dll/default.aspx" /><category term="export" scheme="http://blogs.msdn.com/dhawan/archive/tags/export/default.aspx" /><category term="application" scheme="http://blogs.msdn.com/dhawan/archive/tags/application/default.aspx" /><category term="Win32 API" scheme="http://blogs.msdn.com/dhawan/archive/tags/Win32+API/default.aspx" /></entry><entry><title>Platform Invoke</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/08/23/platform-invoke.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/08/23/platform-invoke.aspx</id><published>2009-08-23T08:20:00Z</published><updated>2009-08-23T08:20:00Z</updated><content type="html">&lt;P&gt;&lt;FONT size=3&gt;Someone asked me, "Why you are so unmanaged?" I said, "Because I work in unmanaged code." and burst into laughter. The gentleman could not understand why I am laughing, but said, "Sometimes you are managed." I could not control myself to laugh and said, "Because sometimes I work in managed code." The gentleman continued to ask, "How do you do that from unmanaged to managed?" Oh My God, "Platform Invoke" I said and keep laughing for few minutes. The gentleman was from Finance domain, so later I explained him the meaning of unmanaged, managed and its conversion in an abstract way. I got an idea to write a blog post about what I know about Platform Invoke. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;Before the advent of Microsoft .NET Framework, the code we used to write in C/C++ language was unmanaged and with .NET Framework the code we write in .NET language ( C#/VB/VC++) is managed. Why the code written in .NET is managed? Because, as a simplest example, when we allocate a memory for any object in .NET, programmer is not responsible to de-allocate/release it, it will be taken care &lt;/FONT&gt;&lt;FONT size=3&gt;by CLR/GC, so managed code, but in legacy/native programming, if we do the same, we are leaking memory. Programmer is responsible to do this, there is no CLR/GC, hence unmanaged code. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;The post is not to discuss any of the .NET feature and compare it with unmanaged stuffs. The article is about Platform Invoke. What is it and how do we do it?&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;.NET Framework class library provides a set of classes to the developers of .NET applications to use it and build applications around it. The class library, internally uses native Win32 API calls to perform the actual task. Sometimes, you will be stuck If you want to do a particular task in your .NET application and there is no class that provides this functionality, It can only be done by a native Win32 API call, e.g. LogonUser(). There is no equivalent class/method to LogonUser() in .NET Framework class library. What will you do? Platform Invoke.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;How do I convert a Win32 API to its equivalent P/Invoke signature?&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;There are couple of ways to do this. First is, Learn P/Invoke, write code and convert API to its .NET equivalent and then call from .NET managed code. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;There has been large amount of text available to learn P/Invoke. &lt;A href="https://apsowa.mail.microsoft.com/redir.aspx?C=ef5180688fa54aa3bb296a37cc1b0741&amp;amp;URL=http%3a%2f%2fwww.microsoft.com%2fen%2fus%2fdefault.aspx" target=_blank mce_href="https://apsowa.mail.microsoft.com/redir.aspx?C=ef5180688fa54aa3bb296a37cc1b0741&amp;amp;URL=http%3a%2f%2fwww.microsoft.com%2fen%2fus%2fdefault.aspx"&gt;Microsoft&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&lt;FONT size=3&gt; and &lt;A href="https://apsowa.mail.microsoft.com/redir.aspx?C=ef5180688fa54aa3bb296a37cc1b0741&amp;amp;URL=http%3a%2f%2fmsdn.microsoft.com%2fhi-in%2fdefault.aspx" target=_blank mce_href="https://apsowa.mail.microsoft.com/redir.aspx?C=ef5180688fa54aa3bb296a37cc1b0741&amp;amp;URL=http%3a%2f%2fmsdn.microsoft.com%2fhi-in%2fdefault.aspx"&gt;MSDN&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=3&gt;&lt;/FONT&gt;&lt;FONT size=3&gt; sites have many documents available, several websites offers tutorials. There are several blogs that talk about the various aspects of P/Invoke. I will try to give references to some of the articles at the end of this post.&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;There are tools available for this purpose. Selecting the name of Win32 API or structure, the tool gives the P/Invoke signature of the API. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=3&gt;Tool from CLR team - &lt;/FONT&gt;&lt;A class="" href="http://blogs.msdn.com/bclteam/archive/2008/06/23/p-invoke-interop-assistant-justin-van-patten.aspx" target=_blank mce_href="http://blogs.msdn.com/bclteam/archive/2008/06/23/p-invoke-interop-assistant-justin-van-patten.aspx"&gt;&lt;FONT size=3&gt;BCL Team Blog : P/Invoke Interop Assistant [Justin Van Patten]&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt; and download - &lt;/FONT&gt;&lt;A class="" href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120" target=_blank mce_href="http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120"&gt;&lt;FONT size=3&gt;Managed, Native, and COM Interop Team - Release: PInvoke Interop Assistant&lt;/FONT&gt;&lt;/A&gt; 
&lt;P&gt;Links of interest-- 
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://blogs.msdn.com/bclteam/" target=_blank mce_href="http://blogs.msdn.com/bclteam/"&gt;BCL Team Blog&lt;/A&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://channel9.msdn.com/posts/funkyonex/The-P-Invoke-Interop-Assistant/" target=_blank mce_href="http://channel9.msdn.com/posts/funkyonex/The-P-Invoke-Interop-Assistant/"&gt;Comments on: The P-Invoke Interop Assistant&lt;/A&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/cc164193.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/magazine/cc164193.aspx"&gt;CLR Inside Out: Marshaling between Managed and Unmanaged Code&lt;/A&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/dd315414.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/magazine/dd315414.aspx"&gt;&lt;FONT size=3&gt;CLR Inside Out: Best Practices For Managed And Native Code Interoperability&lt;/FONT&gt;&lt;/A&gt; 
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/cc501040.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/magazine/cc501040.aspx"&gt;&lt;FONT size=3&gt;MSDN Magazine: CLR Inside Out&lt;/FONT&gt;&lt;/A&gt; 
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://www.bing.com/search?q=Managed+And+Native+Code+Interoperability&amp;amp;go=&amp;amp;form=QBLH&amp;amp;filt=all" target=_blank mce_href="http://www.bing.com/search?q=Managed+And+Native+Code+Interoperability&amp;amp;go=&amp;amp;form=QBLH&amp;amp;filt=all"&gt;Managed And Native Code Interoperability - Bing&lt;/A&gt;&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT size=3&gt;&lt;A href="http://www.bing.com/search?q=Platform+Invoke+Tutorials&amp;amp;form=QBRE&amp;amp;filt=all" target=_blank mce_href="http://www.bing.com/search?q=Platform+Invoke+Tutorials&amp;amp;form=QBRE&amp;amp;filt=all"&gt;Platform Invoke Tutorials - Bing&lt;/A&gt;&lt;/FONT&gt; 
&lt;P&gt;&amp;nbsp;&lt;FONT size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9881332" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="C# .NET" scheme="http://blogs.msdn.com/dhawan/archive/tags/C_2300_+.NET/default.aspx" /><category term="Platform Invoke" scheme="http://blogs.msdn.com/dhawan/archive/tags/Platform+Invoke/default.aspx" /><category term="VB .NET" scheme="http://blogs.msdn.com/dhawan/archive/tags/VB+.NET/default.aspx" /><category term="unmanaged" scheme="http://blogs.msdn.com/dhawan/archive/tags/unmanaged/default.aspx" /><category term="convert" scheme="http://blogs.msdn.com/dhawan/archive/tags/convert/default.aspx" /><category term="managed" scheme="http://blogs.msdn.com/dhawan/archive/tags/managed/default.aspx" /><category term="P/Invoke" scheme="http://blogs.msdn.com/dhawan/archive/tags/P_2F00_Invoke/default.aspx" /><category term=".NET" scheme="http://blogs.msdn.com/dhawan/archive/tags/.NET/default.aspx" /><category term="Win32 API" scheme="http://blogs.msdn.com/dhawan/archive/tags/Win32+API/default.aspx" /></entry><entry><title>Working with Sysinternal tools -1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/08/23/working-with-sysinternal-tools-1.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/08/23/working-with-sysinternal-tools-1.aspx</id><published>2009-08-23T06:22:00Z</published><updated>2009-08-23T06:22:00Z</updated><content type="html">&lt;P&gt;&lt;A href="http://technet.microsoft.com/en-us/sysinternals/default.aspx" mce_href="http://technet.microsoft.com/en-us/sysinternals/default.aspx"&gt;Windows Sysinternals: Documentation, downloads and additional resources&lt;/A&gt; provides a set of tools to get information about various functionalities on the system. The area of information include , process running on the system, file operations, registry operations, TCP/IP related tasks, security etc. The complete list of the tools available can be found here, &lt;A href="http://technet.microsoft.com/en-us/sysinternals/bb545027.aspx" mce_href="http://technet.microsoft.com/en-us/sysinternals/bb545027.aspx"&gt;Sysinternals Utilities&lt;/A&gt;. Though there are separate web-pages to view the introduction of each tool and download the tool, there is a dedicated page to download all the tool at once, &lt;A href="http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx" mce_href="http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx"&gt;Sysinternals Suite&lt;/A&gt; . 
&lt;P&gt;Sysintenals Live, Sysinternals Live is a service that enables you to execute Sysinternals tools directly from the Web without hunting for and manually downloading them. Simply enter a tool’s Sysinternals Live path into Windows Explorer or a command prompt as http://live.sysinternals.com/&amp;lt;toolname&amp;gt; or&amp;nbsp; \\live.sysinternals.com\tools\&amp;lt;toolname&amp;gt;. 
&lt;P&gt;You can view the entire Sysinternals Live tools directory in a browser at &lt;A href="http://live.sysinternals.com/" mce_href="http://live.sysinternals.com/"&gt;http://live.sysinternals.com&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The tools available through sysinternals are very helpful in various troubleshooting scenarios, and I use some of them on daily basis. Here I will try to explain my understanding about the tool and How to I get a particular information through them. It is not possible to demonstrate all of them at once, so this blog-post will get updated over-time whenever I have something to add or edit to it. 
&lt;P&gt;&lt;B&gt;Process Explorer&lt;/B&gt; 
&lt;P&gt;Process Explorer is similar to Windows Task Manager, but shows more information and has extra functionalities to display more information about a process. On display of all the running processes, rather than showing the list of processes, it shows them as tree structure. With tree structure, it is easy to identify which process is parent process and which is child process. For example, If you launch cmd.exe from Start-&amp;gt;Run, you will see that the Explorer is the parent process of cmd.exe . 
&lt;P&gt;The other cool thing I like about Process Explorer is, it give the handle information, which are held by the process, with the type of the handle and which different dlls are loaded in the process address space and their path. It is very helpful in certain scenarios. The type of handle may be, File, Event, Mutex, Registry, Process etc etc. 
&lt;P&gt;How to view handles for a process? 
&lt;P&gt;View-&amp;gt; Lower Pane view-&amp;gt;Handles , there will be a windows in lower half of the process explorer. Select a process from top windows, to view its handles. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image002_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image002_2.jpg"&gt;&lt;IMG title=clip_image002 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=139 alt=clip_image002 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image002_thumb.jpg" width=524 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image002_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp; 
&lt;P&gt;It get refreshed frequently, when a handle is created or deleted, it displays with green or red color. 
&lt;P&gt;How to view Dlls loaded within a process? 
&lt;P&gt;View-&amp;gt; Lower Pane view-&amp;gt;Dlls , there will be a windows in lower half of the process explorer. Select a process from top windows, to view its loaded dlls. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image004_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image004_2.jpg"&gt;&lt;IMG title=clip_image004 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=165 alt=clip_image004 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image004_thumb.jpg" width=368 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image004_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;There is no 64bit version of process explorer, so how a downloaded version which is 32 bit binary can walkthrough the 64 bit process address space and list all the dlls? This is solved by process explorer by a trick. I would assume, When process explorer is launched on a 64bit machine as a 32 bit binary, it checks through it code if it is running on a 64bit machine. If yes, it launches a 64 bit binary from within a 32 bit binary. As below— 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image006_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image006_2.jpg"&gt;&lt;IMG title=clip_image006 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=50 alt=clip_image006 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image006_thumb.jpg" width=372 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image006_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;And procexp.exe has a handle to the process as well. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image008_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image008_2.jpg"&gt;&lt;IMG title=clip_image008 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=76 alt=clip_image008 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image008_thumb.jpg" width=370 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image008_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;The 64 bit exe will get deleted when process explorer is closed. 
&lt;P&gt;Search is a vast business today and an important feature for any product. Process Explorer has a search only for handles or dlls, in all the processes. Standard Ctrl+F will give below dialog. The Find feature has always saved a lot of time for me, to pin point the exact process, rather than search manually for each process. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image010_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image010_2.jpg"&gt;&lt;IMG title=clip_image010 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=209 alt=clip_image010 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image010_thumb.jpg" width=370 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image010_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;Help file is available for Process Explorer. 
&lt;P&gt;&lt;B&gt;TCPView&lt;/B&gt; 
&lt;P&gt;TCP View is another tool which I use frequently to troubleshoot issues with Network programming. Often, it is needed to know that which port has been used by which process and with protocol and who is at the other end. While the same can be retrieved by netstat , but TCP view provides this information in GUI format and with refreshing screens. It is easy to view the behavior of the connections with TCP View in their different states. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image012_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image012_2.jpg"&gt;&lt;IMG title=clip_image012 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=424 alt=clip_image012 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image012_thumb.jpg" width=404 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image012_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;The IP Address can be resolved in machine names as well through options menu. 
&lt;P&gt;The same can be achieved by your own program as well using below APIs. 
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365928(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa365928(VS.85).aspx"&gt;GetExtendedTcpTable Function (Windows)&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/aa365930(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa365930(VS.85).aspx"&gt;GetExtendedUdpTable Function (Windows)&lt;/A&gt;. 
&lt;P&gt;Help file is available for TCPView. 
&lt;P&gt;&lt;B&gt;Process Monitor&lt;/B&gt; 
&lt;P&gt;Process Monitor is another very popular tool which is widely used. Initially there were tools like &lt;A href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" mce_href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx"&gt;Filemon&lt;/A&gt; and &lt;A href="http://technet.microsoft.com/en-us/sysinternals/bb896652.aspx" mce_href="http://technet.microsoft.com/en-us/sysinternals/bb896652.aspx"&gt;Regmon&lt;/A&gt; but later integrated as Process Monitor. Filemon was used for tracing file related operations and Regmon was used for registry related operations. Now, with Process monitor, we have file and registry related operation in one tool and added network and process related operations. As a simple example, if a file has been created, opened, read, write, close or delete on file system, process monitor can record all these activities and can show the details with time, process name, which operation, on which file, the result of the operation and the details of the operation. The same applies to the registry activity. The cool point is, it can show that which threadID of a process has actually performed this activity. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image014_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image014_2.jpg"&gt;&lt;IMG title=clip_image014 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=297 alt=clip_image014 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image014_thumb.jpg" width=733 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image014_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;Using Filter menu, you can restrict your capture, all activities by a particular process, all activities on a particular file or all activities by a particular process on a particular file. It has a lot of filters that can be applied to capture only what we want. Generally I get the complete capture from customer’s site, get the files and then apply needed filters here. Applying the correct set of filters will exactly show you what you want to see in the capture. Network activity can also be monitored from send or receive protocol packets, but I generally used Network Monitor from Microsoft. 
&lt;P&gt;Help file is available for Process Monitor. 
&lt;P&gt;&lt;B&gt;VMMap&lt;/B&gt; 
&lt;P&gt;The other tool is VMMap. VMMap is for Virtual Memory Map. VMMap is used to walk through the virtual address space of the process when selected and gathers the information about which memory is used for which purpose, displays with addresses in different colors. VMMap is helpful to look inside the process, and track any changes. 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image016_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image016_2.jpg"&gt;&lt;IMG title=clip_image016 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=539 alt=clip_image016 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image016_thumb.jpg" width=546 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image016_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;By default it displays the “Total” virtual memory in the lower pane. If you want to see only the loaded images (dlls), then you can select the “Image” from the upper pane list and it will convert as below— 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image018_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image018_2.jpg"&gt;&lt;IMG title=clip_image018 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=169 alt=clip_image018 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image018_thumb.jpg" width=551 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/WorkingwithSysinternaltools1_AF60/clip_image018_thumb.jpg"&gt;&lt;/A&gt; 
&lt;P&gt;Help file is available for VMMap. 
&lt;P&gt;Nitin Dhawan&lt;/P&gt;
&lt;P&gt;Windows SDK - Microsoft&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9881227" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="Virtual Address Space" scheme="http://blogs.msdn.com/dhawan/archive/tags/Virtual+Address+Space/default.aspx" /><category term="vmmap" scheme="http://blogs.msdn.com/dhawan/archive/tags/vmmap/default.aspx" /><category term="tcp" scheme="http://blogs.msdn.com/dhawan/archive/tags/tcp/default.aspx" /><category term="netstat" scheme="http://blogs.msdn.com/dhawan/archive/tags/netstat/default.aspx" /><category term="tcpview" scheme="http://blogs.msdn.com/dhawan/archive/tags/tcpview/default.aspx" /><category term="socket" scheme="http://blogs.msdn.com/dhawan/archive/tags/socket/default.aspx" /><category term="process explorer" scheme="http://blogs.msdn.com/dhawan/archive/tags/process+explorer/default.aspx" /><category term="end point" scheme="http://blogs.msdn.com/dhawan/archive/tags/end+point/default.aspx" /><category term="udp" scheme="http://blogs.msdn.com/dhawan/archive/tags/udp/default.aspx" /><category term="troubleshoot" scheme="http://blogs.msdn.com/dhawan/archive/tags/troubleshoot/default.aspx" /><category term="ip" scheme="http://blogs.msdn.com/dhawan/archive/tags/ip/default.aspx" /><category term="connection" scheme="http://blogs.msdn.com/dhawan/archive/tags/connection/default.aspx" /><category term="sysinternals" scheme="http://blogs.msdn.com/dhawan/archive/tags/sysinternals/default.aspx" /><category term="process monitor" scheme="http://blogs.msdn.com/dhawan/archive/tags/process+monitor/default.aspx" /><category term="developer tools" scheme="http://blogs.msdn.com/dhawan/archive/tags/developer+tools/default.aspx" /><category term="Virtual Memory" scheme="http://blogs.msdn.com/dhawan/archive/tags/Virtual+Memory/default.aspx" /></entry><entry><title>How to setup breakpoint programmatically in source code?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/08/03/how-to-setup-breakpoint-programmatically-in-source-code.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/08/03/how-to-setup-breakpoint-programmatically-in-source-code.aspx</id><published>2009-08-03T21:54:00Z</published><updated>2009-08-03T21:54:00Z</updated><content type="html">&lt;P&gt;Sometimes, you might be in a situation when you want to break in your code at a certain location. You might be trying to put a message box or getch() kind of method for that. There is a direct code to do that, through assembly language. 
&lt;P&gt;int _tmain(int argc, _TCHAR* argv[])&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __asm&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int 3;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;BR&gt;} 
&lt;P&gt;When you will do an F5 ( Start Debugging ) from Visual Studio, then the debugger will break at the point where the instruction int 3; is. Visual Studio gives the message like below-&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/breakpoint.jpg" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/breakpoint.jpg"&gt;&lt;IMG title=breakpoint style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=180 alt=breakpoint src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/breakpoint_thumb.jpg" width=404 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/breakpoint_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You might be thinking that How it is going to help you, you can always do it through setting up a break point on any statement using F9. Below is the scenario where the given code is very helpful. 
&lt;P&gt;You might want to attach &lt;A href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" mce_href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;windbg&lt;/A&gt; to the executable and keep it running until a certain point and then break right there. If you have the debug exe which have the code like above, it will break in windbg right there. 
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/pic2.png" mce_href="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/pic2.png"&gt;&lt;IMG title=pic2 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=154 alt=pic2 src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/pic2_thumb.png" width=544 border=0 mce_src="http://blogs.msdn.com/blogfiles/dhawan/WindowsLiveWriter/Howtosetupbreakpointprogrammaticallyinso_A752/pic2_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This was a small but cool tip, so just wanted to share. 
&lt;P&gt;I am planning to put some more debugging with windbg stuff here. 
&lt;P&gt;Nitin Dhawan 
&lt;P&gt;Windows SDK – Microsoft&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9856446" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="breakpoint" scheme="http://blogs.msdn.com/dhawan/archive/tags/breakpoint/default.aspx" /><category term="windbg" scheme="http://blogs.msdn.com/dhawan/archive/tags/windbg/default.aspx" /><category term="assembly" scheme="http://blogs.msdn.com/dhawan/archive/tags/assembly/default.aspx" /><category term="interrupt" scheme="http://blogs.msdn.com/dhawan/archive/tags/interrupt/default.aspx" /><category term="debugging" scheme="http://blogs.msdn.com/dhawan/archive/tags/debugging/default.aspx" /><category term="Visual Studio" scheme="http://blogs.msdn.com/dhawan/archive/tags/Visual+Studio/default.aspx" /></entry><entry><title>Expecting IGMPv3 packets to go out of the machine, but IGMPv2 packets are going out, What is the problem? </title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/07/27/expecting-igmpv3-packets-to-go-out-of-the-machine-but-igmpv2-packets-are-going-out-what-is-the-problem.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/07/27/expecting-igmpv3-packets-to-go-out-of-the-machine-but-igmpv2-packets-are-going-out-what-is-the-problem.aspx</id><published>2009-07-27T23:59:00Z</published><updated>2009-07-27T23:59:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Possible Scenario:&amp;nbsp; On Windows XP or Windows Server 2003 by default IGMPv3 is enabled. When you send a IGMP multicast packet after joining the multicast group using IP_ADD_SOURCE_MEMBERSHIP and setsockopt(), you see that IGMPv2 packet is going out of the machine, while you are expecting IGMPv3 to go out. What’s wrong? &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Then you check the registry key below to see if you are actually on IGMPv3 or not—&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt"&gt;IGMPVersion&lt;/SPAN&gt;&lt;/B&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Or as per the KB below in “&lt;/FONT&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'"&gt;Configure the registry” &lt;/SPAN&gt;&lt;/B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri"&gt;section.&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;A class="" href="http://support.microsoft.com/kb/815752" target=_blank mce_href="http://support.microsoft.com/kb/815752"&gt;&lt;FONT face=Calibri size=3&gt;You Cannot Configure Windows XP or Windows Server 2003 to Use IGMP Version 1 or Version 2 Support&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;If the value is 4 for IGMPVersion, then your machine is using IGMPv3, your code is correct because may be it is giving right result for some other customer or network. Now what is wrong? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The reason is, if any machine or router in the network is using lower version of IGMP than v3, then the complete network falls back to that version. So, your machine/interface will start using lower version of the IGMP. This is by design. This is clearly demonstrated in ietf website.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;A class="" href="http://www4.ietf.org/proceedings/01mar/slides/idmr-2/sld001.htm" target=_blank mce_href="http://www4.ietf.org/proceedings/01mar/slides/idmr-2/sld001.htm"&gt;&lt;FONT face=Calibri size=3&gt;IGMP Mixed Version Proxying&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; , see slides 11, 12 and 13. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;But I want to send only IGMPv3, no matter if network falls back to lower version if other machine/device is using lower version, What to do?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;No, there is no way to do that. This is by design and as per the RFC.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Other scenario, my machine is configured for IGMPv3, but I am getting the problem as above. Now, if I disable and then enable the interface, I see some IGMPv3 packets going out, but later I get IGMPv2 only, Why?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;When interface get enables and machine is configured to use IGMPv3, it starts sending IGMPv3 packets, but as soon as an IGMPv2 query is received on the interface, it falls back to IGMPv2. Later, it’s all sending out IGMPv2 packets. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;EM&gt;Nitin Dhawan&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;EM&gt;Windows SDK- Microsoft&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9850317" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="IGMPv3" scheme="http://blogs.msdn.com/dhawan/archive/tags/IGMPv3/default.aspx" /><category term="IGMP" scheme="http://blogs.msdn.com/dhawan/archive/tags/IGMP/default.aspx" /><category term="IP_ADD_SOURCE_MEMBERSHIP" scheme="http://blogs.msdn.com/dhawan/archive/tags/IP_5F00_ADD_5F00_SOURCE_5F00_MEMBERSHIP/default.aspx" /><category term="IGMPv2" scheme="http://blogs.msdn.com/dhawan/archive/tags/IGMPv2/default.aspx" /><category term="IGMPVersion" scheme="http://blogs.msdn.com/dhawan/archive/tags/IGMPVersion/default.aspx" /><category term="setsockopt" scheme="http://blogs.msdn.com/dhawan/archive/tags/setsockopt/default.aspx" /><category term="IP_ADD_MEMBERSHIP" scheme="http://blogs.msdn.com/dhawan/archive/tags/IP_5F00_ADD_5F00_MEMBERSHIP/default.aspx" /></entry><entry><title>Mapped Drive - Can't create Mapped Drive / Can't access Mapped Drive. What's happenning?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/07/16/mapped-drive-can-t-create-mapped-drive-can-t-access-mapped-drive-what-s-happenning.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/07/16/mapped-drive-can-t-create-mapped-drive-can-t-access-mapped-drive-what-s-happenning.aspx</id><published>2009-07-17T01:13:00Z</published><updated>2009-07-17T01:13:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Developing with mapped drives on Windows machines, you can often get the similar messages like subject of this article. What’s wrong? &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Even sometimes, you can see the mapped drive in explorer or using&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;“net use”, but still your application can’t use it. Why? &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;The information has been documented on many KBs on &lt;/FONT&gt;&lt;A href="http://support.microsoft.com/"&gt;&lt;FONT face=Calibri size=3&gt;http://support.microsoft.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; like link below, but I am just trying to convey the message in different words. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://support.microsoft.com/kb/180362"&gt;&lt;FONT face=Calibri size=3&gt;INFO: Services and Redirected Drives&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Reason:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The information can be found documented at many places, I just want to point on the documentation of the API which is used to create mapped drive programmatically, &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa385413(VS.85).aspx"&gt;&lt;FONT face=Calibri size=3&gt;WNetAddConnection2 Function (Windows)&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;, see Remarks Section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: auto 0in; VERTICAL-ALIGN: top; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: black; LINE-HEIGHT: 140%; FONT-FAMILY: 'Verdana','sans-serif'"&gt;Remarks&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P style="VERTICAL-ALIGN: top; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; LINE-HEIGHT: 140%; FONT-FAMILY: 'Verdana','sans-serif'"&gt;On Windows Server&amp;nbsp;2003 and Windows&amp;nbsp;XP, the WNet functions create and delete network drive letters in the MS-DOS device namespace associated with a logon session because MS-DOS devices are identified by AuthenticationID (a &lt;A id=ctl00_MTContentSelector1_mainContentContainer_ctl10 href="http://msdn.microsoft.com/en-us/library/ms721592(VS.85).aspx"&gt;locally unique identifier&lt;/A&gt;, or LUID, associated with a logon session.) This can affect applications that call one of the WNet functions to create a network drive letter under one user logon, but query for existing network drive letters under a different user logon. An example of this situation could be when a user's second logon is created within a logon session, for example, by calling the &lt;A id=ctl00_MTContentSelector1_mainContentContainer_ctl11 href="http://msdn.microsoft.com/en-us/library/ms682429(VS.85).aspx"&gt;&lt;STRONG&gt;&lt;SPAN style="COLOR: #0033cc; FONT-FAMILY: 'Verdana','sans-serif'; TEXT-DECORATION: none; text-underline: none"&gt;CreateProcessAsUser&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt; function, and the second logon runs an application that calls the &lt;A id=ctl00_MTContentSelector1_mainContentContainer_ctl12 href="http://msdn.microsoft.com/en-us/library/aa364972(VS.85).aspx"&gt;&lt;STRONG&gt;&lt;SPAN style="COLOR: #0033cc; FONT-FAMILY: 'Verdana','sans-serif'; TEXT-DECORATION: none; text-underline: none"&gt;GetLogicalDrives&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt; function. The call to the &lt;STRONG&gt;&lt;SPAN style="FONT-FAMILY: 'Verdana','sans-serif'"&gt;GetLogicalDrives&lt;/SPAN&gt;&lt;/STRONG&gt; function does not return network drive letters created by WNet function calls under the first logon. Note that in the preceding example the first logon session still exists, and the example could apply to any logon session, including a Terminal Services session. For more information, see &lt;A id=ctl00_MTContentSelector1_mainContentContainer_ctl13 href="http://msdn.microsoft.com/en-us/library/aa363908(VS.85).aspx"&gt;Defining an MS-DOS Device Name&lt;/A&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;So, if you create the mapped drive through explorer under user’s context and try to use it through a web application running under NETWORK SERVICE, the application code will fail to use mapped drive. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;You can test it non-programmatically as well. I used Windows Vista for this demo.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Launch a command prompt as logged on user. Type below command.&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 1in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Net use&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="file://machinename/share"&gt;&lt;FONT face=Calibri size=3&gt;\\machinename\share&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;If it is successful, the mapped drive will be created.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Launch a command prompt as “runas /user:someuser2 cmd.exe” by giving the password for “someuser2” . Type below command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 1in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Net use&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;You will see that the drive is not available, but in explorer windows you can see it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now from the command prompt launched in #2, run below command. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 1in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Net use &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;k:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="file://machinename2/share"&gt;&lt;FONT face=Calibri size=3&gt;\\machinename2\share&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;If it is successful, the mapped drive will be created.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Two mapped drives with same drive letter, with different target, on same machine…..?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now you have two mapped drive created on the same system with same drive letter but to two different locations. How do you test it? &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;You can see the mapped drive created in #1 through explorer. Switch user to “someuser2” and see if there is another mapped drive created, which you created in #3.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Observe the difference.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Mapped drives are restricted to per user. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;I think above information is good enough to explain that mapped drives are strictly restricted to user specific. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Nitin Dhawan&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Windows SDK – Microsoft&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9836180" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="mapped drive" scheme="http://blogs.msdn.com/dhawan/archive/tags/mapped+drive/default.aspx" /><category term="CreateProcessAsUser" scheme="http://blogs.msdn.com/dhawan/archive/tags/CreateProcessAsUser/default.aspx" /><category term="GetLogicalDrives" scheme="http://blogs.msdn.com/dhawan/archive/tags/GetLogicalDrives/default.aspx" /><category term="net use" scheme="http://blogs.msdn.com/dhawan/archive/tags/net+use/default.aspx" /><category term="LogonUser" scheme="http://blogs.msdn.com/dhawan/archive/tags/LogonUser/default.aspx" /></entry><entry><title>Mapped drives can’t be created after Microsoft Security Update from code running under Network Service account</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/07/14/mapped-drives-can-t-be-created-after-microsoft-security-update-from-code-running-under-network-service-account.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/07/14/mapped-drives-can-t-be-created-after-microsoft-security-update-from-code-running-under-network-service-account.aspx</id><published>2009-07-15T00:42:00Z</published><updated>2009-07-15T00:42:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Mapped drives can’t be created after Microsoft Security Update from code running under Network Service account&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A class="" href="http://support.microsoft.com/kb/956572" target=_blank mce_href="http://support.microsoft.com/kb/956572"&gt;&lt;FONT face=Calibri size=3&gt;MS09-012: Description of the security update for Windows Service Isolation: April 2009&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;( KB 956572 )&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Possible scenario: You are using web application running under Network Service account and the code creates mapped drives using WNetAddConnection* APIs and fails stating ERROR_ALREADY_ASSIGNED error 85.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;With this update installed on the machine, you will not be able to create mapped drive from the Network Service account. This is&amp;nbsp;intentionally blocked for Network Service account. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Uninstalling the security update, Network Service account is able to create the mapped drive through WNetAddConnection* API successfully. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;Verify if this is the case and options to workaround--&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;#1, If you have this issue, see if the update is installed on your machine. Check though Control Panel Installed Programs and updates or type “systeminfo” on command prompt.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;#2, To make sure this is the issue, see if you can uninstall the update. If after uninstalling the update, if your code in Network Service is able to create the mapped drive, then security update was causing it to fail. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;#3, Recommendation is, try using a different account to run the application which will make the application and security update to co-exist on the machine. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;#4, else If it is not at all possible then try below registry change to revert back the changes of update in this regard. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Key- &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager”&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProtectionMode &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Restart the machine to take it in effect. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Thanks. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Nitin Dhawan&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9833574" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="mapped drive" scheme="http://blogs.msdn.com/dhawan/archive/tags/mapped+drive/default.aspx" /><category term="WNetAddConnection" scheme="http://blogs.msdn.com/dhawan/archive/tags/WNetAddConnection/default.aspx" /><category term="956572" scheme="http://blogs.msdn.com/dhawan/archive/tags/956572/default.aspx" /><category term="ProtectionMode" scheme="http://blogs.msdn.com/dhawan/archive/tags/ProtectionMode/default.aspx" /><category term="ERROR_ALREADY_ASSIGNED" scheme="http://blogs.msdn.com/dhawan/archive/tags/ERROR_5F00_ALREADY_5F00_ASSIGNED/default.aspx" /><category term="Network Service" scheme="http://blogs.msdn.com/dhawan/archive/tags/Network+Service/default.aspx" /></entry><entry><title>File.Exists /_access / GetFileAttributes / FindFirstFile,FindNextFile / _stat  behavior over SMB 2.0</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/dhawan/archive/2009/07/10/file-exists-access-getfileattributes-findfirstfile-findnextfile-stat-behavior-over-smb-2-0.aspx" /><id>http://blogs.msdn.com/dhawan/archive/2009/07/10/file-exists-access-getfileattributes-findfirstfile-findnextfile-stat-behavior-over-smb-2-0.aspx</id><published>2009-07-10T20:47:00Z</published><updated>2009-07-10T20:47:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Problem Observed: When an application on client creates a file on a shared directory on server or application on server creates a file on shared directory on server, and file is created successfully but when the application on client try to check the existence of the recently created file by _access or other method, it reports that the file does not exists. This behavior is observed when SMB 2.0 is used.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;SMB 2.0 was introduced on Windows Vista and Windows Server 2008. The file does exists about after 10+ seconds. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Is it a bug with SMB 2.0 ? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;No it is not a bug.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Is this by design with SMB 2.0? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Yes, this is a design change with SMB 2.0. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;What is really happening? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;This is because of the local caching included on the client side with SMB 2.0. When the SMB 2.0 session has been created, the local cache will be available on the client side, which will be refreshed after every 10 seconds by default. Any further request to the file exists will be checked against this local cache rather than going to the server share. So, if a local cache is built on client, and on server share a new file is created, local cache has not been invalidated and not in sync with server share, any further request for checking the new file existence will fail. This is root cause, but by design. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;If the local cache is updated and in sync with server share, request will be successful. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;How do I control the local cache lifetime? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;You can create registry keys below to control the cache lifetime.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Under &amp;nbsp;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;FileInfoCacheLifetime&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;FileNotFoundCacheLifetime&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;DirectoryCacheLifetime&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;They are all REG_DWORD type in seconds.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Programmatic workaround? &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Register for directory or file change notifications using Win32 API. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Use &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa364417(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa364417(VS.85).aspx"&gt;&lt;FONT face=Calibri size=3&gt;FindFirstChangeNotification Function (Windows)&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; API to register for changes. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Sample can be found here &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx"&gt;&lt;FONT face=Calibri size=3&gt;Obtaining Directory Change Notifications (Windows)&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Open for any questions here. Thanks. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Nitin Dhawan &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Windows SDK - Microsoft&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9828917" width="1" height="1"&gt;</content><author><name>Dhawan</name><uri>http://blogs.msdn.com/members/Dhawan.aspx</uri></author><category term="FindNextFile" scheme="http://blogs.msdn.com/dhawan/archive/tags/FindNextFile/default.aspx" /><category term="File.Exists" scheme="http://blogs.msdn.com/dhawan/archive/tags/File.Exists/default.aspx" /><category term="_stat" scheme="http://blogs.msdn.com/dhawan/archive/tags/_5F00_stat/default.aspx" /><category term="FindFirstFile" scheme="http://blogs.msdn.com/dhawan/archive/tags/FindFirstFile/default.aspx" /><category term="GetFileAttributes" scheme="http://blogs.msdn.com/dhawan/archive/tags/GetFileAttributes/default.aspx" /><category term="_access" scheme="http://blogs.msdn.com/dhawan/archive/tags/_5F00_access/default.aspx" /><category term="CreateFile" scheme="http://blogs.msdn.com/dhawan/archive/tags/CreateFile/default.aspx" /><category term="Windows Server 2008" scheme="http://blogs.msdn.com/dhawan/archive/tags/Windows+Server+2008/default.aspx" /><category term="Windows Vista" scheme="http://blogs.msdn.com/dhawan/archive/tags/Windows+Vista/default.aspx" /></entry></feed>