<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'How to backup using backup API's in c++' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'How to backup using backup API's in c++' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Mon, 17 Jun 2013 23:58:57 -0700</pubDate>
    <lastBuildDate>Mon, 17 Jun 2013 23:58:57 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>How to backup using backup API's in c++</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/430158/430158/how-to-backup-using-backup-apis-in-c++/</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
I am writing an application that used to backup some specified file, therefore using the backup API calls i.e CreateFile BackupRead and WriteFile.&lt;br /&gt;
&lt;br /&gt;
getting Access violation reading location.&lt;br /&gt;
&lt;br /&gt;
I have attached code below.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;#include &amp;lt;windows.h&amp;gt;

int main()
{
	HANDLE hInput, hOutput;
	
	//m_filename is a variable holding the file path to read from
	hInput = CreateFile(L"C:\\Key.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
	
	//strLocation contains the path of the file I want to create.
	hOutput= CreateFile(L"C:\\tmp\\", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, NULL, NULL); 
 
    
	DWORD dwBytesToRead = 1024 * 1024 * 10;
    BYTE *buffer;
    buffer = new BYTE[dwBytesToRead];
	BOOL bReadSuccess = false,bWriteSuccess = false;
	DWORD dwBytesRead,dwBytesWritten;
	LPVOID lpContext;
	//Now comes the important bit:
 
    do
    {
        bReadSuccess = BackupRead(hInput, buffer, sizeof(BYTE) *dwBytesToRead, &amp;amp;dwBytesRead, false, true, &amp;amp;lpContext);
 	
        bWriteSuccess= WriteFile(hOutput, buffer, sizeof(BYTE) *dwBytesRead, &amp;amp;dwBytesWritten, NULL); 
 
    }while(dwBytesRead == dwBytesToRead);

	return 0;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Any one suggest me how to use these API's?&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/430158/430158/how-to-backup-using-backup-apis-in-c++/</guid>
      <pubDate>Wed, 07 Nov 2012 20:45:31 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>