<?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>Code Library &#187; win32</title>
	<atom:link href="http://www.ucosoft.com/tag/win32/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Mon, 19 Jul 2010 04:51:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to read sectors of a physical drive under Win32?</title>
		<link>http://www.ucosoft.com/how-to-read-sectors-of-a-physical-drive-under-win32.html</link>
		<comments>http://www.ucosoft.com/how-to-read-sectors-of-a-physical-drive-under-win32.html#comments</comments>
		<pubDate>Mon, 15 Jan 2007 15:44:52 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/archives/74.html</guid>
		<description><![CDATA[How to read the sectors of physical drive under win32? The API ReadFile is most useful function, and with it, you can read the physical sectors directly. Here is a sample function, BOOL ReadSectors(&#8230;) BOOL ReadSectors( BYTE bDrive, //drive index DWORD dwStartSector, //start sector WORD wSectors, //sectors number LPBYTE lpSectBuff) { ã€€if (bDrive == 0)]]></description>
			<content:encoded><![CDATA[<p><P>How to read the sectors of physical drive under win32? </p>
<p>The API ReadFile is most useful function, and with it, you can read the physical sectors directly.</p>
<p>Here is a sample function, <b>BOOL ReadSectors(&#8230;)</B><br />
</P><br />
<coolcode lang="cpp" linenum="no" download="ReadSector.cpp"><br />
BOOL ReadSectors(<br />
    BYTE bDrive,  //drive index<br />
    DWORD dwStartSector, //start sector<br />
    WORD wSectors,         //sectors number<br />
    LPBYTE lpSectBuff)<br />
{<br />
ã€€if (bDrive == 0) return 0;<br />
ã€€char devName[] = &#8220;\\\\.\\A:&#8221;;<br />
ã€€devName[4] =&#8217;A&#8217; + bDrive &#8211; 1;<br />
ã€€HANDLE hDev = CreateFile(devName, GENERIC_READ,<br />
                         FILE_SHARE_WRITE, NULL,<br />
                         OPEN_EXISTING, 0, NULL);<br />
ã€€if (hDev == INVALID_HANDLE_VALUE) return 0;<br />
ã€€SetFilePointer(hDev, 512 * dwStartSector,<br />
            0, FILE_BEGIN);<br />
ã€€DWORD dwCB;<br />
ã€€BOOL bRet = ReadFile(hDev, lpSectBuff,<br />
                 512 * wSectors, &#038;dwCB, NULL);<br />
ã€€CloseHandle(hDev);<br />
ã€€return bRet;<br />
}<br />
</coolcode></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/api" title="API" rel="tag">API</a>, <a href="http://www.ucosoft.com/tag/how-to" title="How-to" rel="tag">How-to</a>, <a href="http://www.ucosoft.com/tag/sdk" title="sdk" rel="tag">sdk</a>, <a href="http://www.ucosoft.com/tag/win32" title="win32" rel="tag">win32</a></strong><br />

	<ul class="st-related-posts">
	<li><a href="http://www.ucosoft.com/write-and-read-binary-data-in-variant.html" title="Write and read binary data in VARIANT (November 22, 2006)">Write and read binary data in VARIANT</a> (0)</li>
	<li><a href="http://www.ucosoft.com/set-the-head-backgroud-color-of-cpropertypage.html" title="Set the head backgroud color of CPropertyPage (October 18, 2007)">Set the head backgroud color of CPropertyPage</a> (0)</li>
	<li><a href="http://www.ucosoft.com/intermittent-work-in-ui-thread-2.html" title="Intermittent work in UI thread (October 16, 2007)">Intermittent work in UI thread</a> (0)</li>
	<li><a href="http://www.ucosoft.com/intermittent-work-in-ui-thread.html" title="Intermittent work in UI thread (October 16, 2007)">Intermittent work in UI thread</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-translate-among-cstringstring-and-char-array.html" title="How to translate among CString,string and char array (June 22, 2007)">How to translate among CString,string and char array</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-subclass-ctreectrl-in-ctreeview.html" title="How to subclass CTreeCtrl in CTreeView? (October 25, 2007)">How to subclass CTreeCtrl in CTreeView?</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-sort-items-of-clistctrl-or-clistview.html" title="How to sort items of CListCtrl or CListView? (October 22, 2007)">How to sort items of CListCtrl or CListView?</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-sendpost-message-to-cdocument.html" title="How to send/post message to CDocument? (October 24, 2007)">How to send/post message to CDocument?</a> (2)</li>
	<li><a href="http://www.ucosoft.com/how-to-launch-an-application-with-admin-privileges-in-vista.html" title="How to launch an Application with Admin privileges in VISTA (March 8, 2007)">How to launch an Application with Admin privileges in VISTA</a> (0)</li>
	<li><a href="http://www.ucosoft.com/get-clistctrl-item-text-of-another-process.html" title="How to get ClistCtrl item text of another process (September 24, 2008)">How to get ClistCtrl item text of another process</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-read-sectors-of-a-physical-drive-under-win32.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
