특정 파일을 백업하는 데 사용하는 응용 프로그램을 작성 중이므로 백업 API 호출을 사용합니다. 즉, CreateFile BackupRead 및 WriteFile API의입니다.C에서 백업 API를 사용하여 백업하는 방법
액세스 오류 읽기 위치가 잘못되었습니다.
아래 코드를 첨부했습니다.
#include <windows.h>
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, &dwBytesRead, false, true, &lpContext);
bWriteSuccess= WriteFile(hOutput, buffer, sizeof(BYTE) *dwBytesRead, &dwBytesWritten, NULL);
}while(dwBytesRead == dwBytesToRead);
return 0;
}
어떤 하나의 방법이 API의의를 사용하는 날을 제안?
감사합니다.
Vista에서 Windows 8로가는 창이 없기 때문에 프로그램 – billz
의 C : 디렉토리에 파일을 만들 수 있습니다. 예를 들어, 대상 위치는 아무거나 ... – user1603185