<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; sfc.h</title>
	<atom:link href="http://weseetips.com/tag/sfc-h/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Windows File Protection &#8211; How to check whether the file is protected?</title>
		<link>http://weseetips.com/2008/12/15/windows-file-protection-how-to-check-whether-the-file-is-protected/</link>
		<comments>http://weseetips.com/2008/12/15/windows-file-protection-how-to-check-whether-the-file-is-protected/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 20:29:55 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Windows APIs]]></category>
		<category><![CDATA[check protected file]]></category>
		<category><![CDATA[check system file]]></category>
		<category><![CDATA[sfc]]></category>
		<category><![CDATA[sfc.h]]></category>
		<category><![CDATA[SfcGetNextProtectedFile]]></category>
		<category><![CDATA[SfcIsFileProtected]]></category>
		<category><![CDATA[SfcIsFileProtected vista]]></category>
		<category><![CDATA[system file check]]></category>
		<category><![CDATA[WFP]]></category>
		<category><![CDATA[windows file protection]]></category>
		<category><![CDATA[windows resource protection]]></category>
		<category><![CDATA[WRP]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=711</guid>
		<description><![CDATA[Windows have got a set of files which are essential to the working of system. Chances are lot that those files to be corrupted accidentally or intentionally. But windows have taken care about it and those files are under protection. So if your user selects the filename of a protected system file to save his [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.wordpress.com/files/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
<span style="color:#0000ff;"> Windows have got a set of files which are essential to the working of system.</span> Chances are lot that those files to be corrupted accidentally or intentionally. But windows have taken care about it and those files are under protection. So if your user selects the filename of a protected system file to save his data, its the duty of a responsible windows citizen  application to check whether its a system file and to warn the user. <span style="color:#0000ff;">Well, how to check whether the file is a protected system file?</span></p>
<p><span style="color:#0000ff;"><img class="alignnone size-full wp-image-716" title="windowsresourceprotection" src="http://weseetips.wordpress.com/files/2008/12/windowsresourceprotection.jpg" alt="windowsresourceprotection" width="479" height="383" /><br />
</span></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.wordpress.com/files/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You could use the function &#8211; <span style="color:#0000ff;">SfcIsFileProtected()</span>. Check the code snippet.</p>
<pre>#include "Sfc.h"
...
// Check whether the file is protected or not.
WCHAR* pProtectedFile = L"C:\\Windows\\system32\\kernel32.dll";
BOOL bProtected = SfcIsFileProtected( NULL, pProtectedFile );</pre>
<p><span style="text-decoration:underline;"><strong>How to get the list of protected files?</strong></span><br />
Well, <span style="color:#0000ff;">iterating the protected file list </span>will be nice. isn&#8217;t it? You can use the function &#8211; <span style="color:#0000ff;">SfcGetNextProtectedFile()</span> for that. Check the code snippet below.</p>
<pre>// Get the protected file list - one by one.
PROTECTED_FILE_DATA ProtectedFileInfo = { 0 };
while( SfcGetNextProtectedFile( NULL, &amp;ProtectedFileInfo ))
{
    // Print the filename.
    cout &lt;&lt; ProtectedFileInfo.FileName &lt;&lt; endl;
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.wordpress.com/files/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Well, for some reason the <strong><span style="color:#0000ff;">SfcGetNextProtectedFile() is removed from vista.</span></strong> So <span style="color:#000000;">keep in mind that it will work only on XP and 2000 machines.</span> Well, don&#8217;t forget to include <span style="color:#0000ff;">sfc.lib </span>in your project settings. <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-medium wp-image-51" title="beginnerseries" src="http://weseetips.wordpress.com/files/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/12/15/windows-file-protection-how-to-check-whether-the-file-is-protected/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

