for (int I=0; i<=2; I++) { HANDLE fp=CreateFile (TEXT (" D://jyzhj2. Rar "),//input here need to copy the file SRC GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN. NULL); If (fp==NULL) { MessageBox (L "error"); } DWORD dwBytesInBlock=GetFileSize (fp, NULL);//file size HANDLE hFileMapping=CreateFileMapping (fp, NULL, PAGE_READWRITE, 0,//(DWORD) (dwBytesInBlock & gt;> 16), DwBytesInBlock,//(DWORD) (dwBytesInBlock & amp; 0 x0000ffff), NULL); Int dwError=GetLastError (); //release the file the kernel object The CloseHandle (fp); //offset __int64 qwFileOffset=0; //the file data is mapped to the process's address space LPVOID pbFile=MapViewOfFile (hFileMapping, FILE_MAP_ALL_ACCESS, (DWORD) (qwFileOffset & gt;> 32), (DWORD) (qwFileOffset & amp; 0 XFFFFFFFF), DwBytesInBlock); HANDLE wp=CreateFile (TEXT (" D://xianjian 5. Rar "),//it need paste file DST GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_WRITE_THROUGH, NULL); HANDLE hFileMapping2=CreateFileMapping (wp, NULL, PAGE_READWRITE, 0,//(DWORD) (dwBytesInBlock & gt;> 16), DwBytesInBlock,//(DWORD) (dwBytesInBlock & amp; 0 x0000ffff), NULL); The CloseHandle (wp); LPVOID pbFile2=MapViewOfFile (hFileMapping2, FILE_MAP_ALL_ACCESS, (DWORD) (qwFileOffset & gt;> 32), (DWORD) (qwFileOffset & amp; 0 XFFFFFFFF), DwBytesInBlock); Memcpy (pbFile2 pbFile, dwBytesInBlock); UnmapViewOfFile (pbFile2); UnmapViewOfFile (pbFile); The CloseHandle (hFileMapping2); The CloseHandle (hFileMapping); } Have been memcpy (pbFile2 pbFile, dwBytesInBlock); Interrupt
Mapping. Exe of 0 x1023fde0 (msvcr90d. DLL) the most possible exceptions: 0 xc0000005: access conflict while reading position 0 x00000000
Mapping. Exe of 0 x1023fde0 (msvcr90d. DLL) an unhandled exception: 0 xc0000005: access conflict while reading position 0 x00000000
CodePudding user response:
CodePudding user response:
CodePudding user response:
A novice for guidance
CodePudding user response:
Check whether there is pbFile MapViewOfFile function of each parameter setting on
CodePudding user response:
Check the error code, etc., GetLastError
CodePudding user response:
reference 5 floor oyljerry reply: check the error code, etc., GetLastError Error code is 87, parameter error? CodePudding user response:
What I want is to write the data of a file to another file, wireless, the bigger the better, what should I do CodePudding user response:
Fread fwrite CodePudding user response:
caution is ten thousand ship! Fyi: # include & lt; Sys/stat. H> #include #include #include #include #include #include #include # define MAX_CLU_BYTES 65536 The FILE * fo; Int fh. __int64 offs, offs1; __int64 rvi64; Int the rv, WRV; Unsigned char buf [MAX_CLU_BYTES]; Char ofn [_MAX_PATH]; Char offstr [80]. Char drive [_MAX_DRIVE]; Char dir [_MAX_DIR]; Char fname [_MAX_FNAME]; Char ext [_MAX_EXT]; Char fullpath [_MAX_PATH]; Void strcpybutcomma (char * t, char * s) { char c; While (1) { C=* s++; If (', '! * t++=c=c); If (0==c) break; } } Int main (int arg c, char * * argv) { If (argc<3) { Printf (" Copy File Tail. \ n "); Usage: printf (" \ n "); Printf (" CFT is filename. Ext {Offset_Begin | - Offset_End | Offset_Begin - Offset_End} \ n "); Printf (" Copy filename. Ext {OB | - OE | OB - OE} to {OB | ~ OE | OB - OE} - filename. Ext \ n "); Printf (" Note: Byte at OE is NOT included. \ n "); Example: printf (" \ n "); Printf (" CFT is ABC. Rar 12345 \ n "); Printf (" Copy ABC. Rar offset 12345 - end to 12345 - ABC. Rar \ n "); Printf (" \ n CFT is ABC. Rar - 12345 "); Printf (" Copy ABC. Rar offset the to - 12345-12345 - end - ABC. Rar \ n "); Printf (" CFT is ABC. Rar, 123-12345 \ n "); Printf (" Copy ABC. Rar offset of 123-12345 to 123-12345 - ABC. Rar \ n "); Printf (" CFT is ABC. Rar xab 0-0 XCD \ n "); Printf (" Copy ABC. Rar offset 0 xab xab XCD 0 to 0-0 XCD - ABC. Rar \ n "); return 1; } Strcpybutcomma (offstr, argv [2]); The rv=sscanf (offstr, "% I64i - % I64i", & amp; Offs, & amp; Offs1); If (rv==0) { Printf (" is not number offset % s \ n ", argv [2]). Return 2; } If (NULL==_fullpath (fullpath, argv [1], _MAX_PATH)) { nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull