The following bit of code is only the memory mapping part, but I am unsure about the output area of the code. I know how to bring in an input file, but I am unsure if this code sends out an output file. Also, is there a reference site that I can be pointed to about how to write to the output file. I am stuck on trying to figure out how to get the information from the first file (the input) to the second file (the output). I am pretty sure the code below is incomplete, only on the reason of I don't know how to connect it, and I can't find the correct reading sources to help me out. Thank you in advance. -
#include <windows.h>
-
#include <iostream>
-
using namespace std;
-
-
int main()
-
{
-
HANDLE OutFile;
-
HANDLE InFile;
-
HANDLE InFileMap;
-
HANDLE OutFileMap;
-
PVOID InPVFile;
-
PVOID OutPVFile;
-
DWORD InDWFileSize;
-
DWORD OutDWFileSize;
-
int i;
-
-
//Opening an input file.
-
-
char OutFilename[] = “c:\\exe1\\testin.dat”;
-
-
OutFile = CreateFile(InFilename,
-
GENERIC_READ,
-
0,
-
NULL,
-
OPEN_EXISTING,
-
FILE_ATTRIBUTE_NORMAL,
-
NULL);
-
if (InFile == INVALID_HANDLE_VALUE)
-
{
-
cout << “File could not be opened.”;
-
return(FALSE);
-
}
-
-
//Creating a file-mapping kernel object for input.
-
-
InFileMap = CreatFileMapping(InFile,
-
NULL,
-
PAGE_READONLY,
-
0,
-
0,
-
NULL);
-
if (InFileMap == NULL)
-
{
-
cout << “File map could not be opened.”;
-
ClosrHandle(InFile);
-
return(FALSE);
-
}
-
-
//Mapping a view of the input file.
-
-
InPVFile = MapViewOfFile(InFileMap,
-
FILE_MAP_READ,
-
0,
-
0,
-
0);
-
if (InPVFile == NULL)
-
{
-
cout << “Could not map view of file.”;
-
CloseHandle(InFileMap);
-
CloseHandle(InFile);
-
return(FALSE);
-
}
-
-
//Gathering the size of the input file.
-
-
InDWFileSize = GetFileSize(InFile, NULL);
-
-
//Creating an output file.
-
-
char OutFilename[] = “c:\\exe1\\testout.dat”;
-
-
OutFile = CreateFile(OutFilename,
-
GENERIC_READ | GENERIC_WRITE,
-
0,
-
NULL,
-
CREATE_NEW,
-
FILE_ATTRIBUTE_NORMAL,
-
NULL);
-
if (OutFile == INVALID_HANDLE_VALUE)
-
{
-
cout << “File could not be created.”;
-
return(FALSE);
-
}
-
-
//Creating a file-mapping kernel object for output.
-
-
OutFileMap = CreatFileMapping(OutFile,
-
NULL,
-
PAGE_WRITECOPY,
-
0,
-
0,
-
NULL);
-
if (OutFileMap == NULL)
-
{
-
cout << “File map could not be created.”;
-
ClosrHandle(OutFile);
-
return(FALSE);
-
}
-
-
//Mapping a view of the output file.
-
-
OutPVFile = MapViewOfFile(OutFileMap,
-
FILE_MAP_COPY,
-
0,
-
0,
-
0);
-
if (OutPVFile == NULL)
-
{
-
cout << “Could not map view of file.”;
-
CloseHandle(OutFileMap);
-
CloseHandle(OutFile);
-
return(FALSE);
-
}
-
-
//Switching the ASCII characters.
-
-
//???
-
-
//Housekeeping
-
-
UnmapViewOfFile(InPVFile);
-
UnmapViewOfFile(OutPVFile);
-
CloseHandle(InFileMap);
-
CloseHandle(OutFileMap);
-
CloseHandle(InFile);
-
CloseHandle(OutFile);
-
}
-
1 2287 Banfa 9,065
Recognized Expert Moderator Expert
This looks like a rather complex way to copy a file when you could just call CopyFileEx Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jason Callas |
last post by:
I was doing starting some experimenting with the GC and ran into the following odd result. I created an object and my used memory went up by almost 11k but when I cleared it and forced a collection...
|
by: Tron Thomas |
last post by:
Given the following information about memory management in C++:
-----
The c-runtime dynamic memory manager (and most other commercial memory
managers) has issues with fragmentation similar to a...
|
by: John |
last post by:
Hi all:
When I run my code, I find that the memory that the code uses keeps
increasing.
I have a PC with 2G RAM running Debian linux. The code consumes 1.5G
memory by the time it finishes...
|
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but...
|
by: Zeng |
last post by:
I finally narrowed down my code to this situation, quite a few (not all) of
my CMyClass objects got hold up after each run of this function via the
simple webpage that shows NumberEd editbox. My...
| |
by: Adrian |
last post by:
Hi
I have a JS program that runs localy (under IE6 only) on a PC but it has
a memory leak (probably the known MS one!)
What applications are there that I could use to look at the memory usage of...
|
by: ivan.leben |
last post by:
How can I really delete a preloaded image from memory/disk cache? Let's
say I preload an image by creating an Image object and setting its src
attribute to desired URL:
var img = new Image();...
|
by: Peter Olcott |
last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY
exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system
so I am not even out of physical RAM, much...
|
by: kumarmdb2 |
last post by:
Hi guys,
For last few days we are getting out of private memory error. We have a
development environment. We tried to figure out the problem but we
believe that it might be related to the OS...
|
by: cham |
last post by:
Hi,
I am working on c++ in a linux system ( Fedora core 4 ),
kernel version - 2.6.11-1.1369_FC4
gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 )
In my code i am creating a vector to store...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |