|
It doesn't copy any data, it just maps the file into your process address space for you to access as a byte array. Memory paging takes care of the details, and makes sure the parts you are accessing is swapped into RAM.
|
|
|
|
|
thanx for the reply.but i didnt get ur answer completely.....
'and makes sure the parts you are accessing is swapped into RAM'
i didnt follow this line!does this above statement mean that if i were to change the contents of the file ,then these changes are updated in the RAM and finally written on the file?but then if i am making a change in the file directly,then what is the need for this MapViewOfFile ,coz either way i get the change!
can u please elaborate?
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
You mean, why use memory mapped files when the ordinary I/O functions also work? The answer is performance. Memory mapped files are extremly efficient if you want to handle large files.
Did that answer your question?
|
|
|
|
|
Niklas Lindquist wrote:
The answer is performance. Memory mapped files are extremly efficient if you want to handle large files.
I dont know about performance, but they definitely provide you simplicity in terms reading and writing files yourselves using the file management APIs.
I have a couple of questions on CreateFileMapping:
- CreateFileMapping returns success if both the handle parameter is NULL, and the Name parameter is NULL. What purpose does this mapping serve?
- How can we change the read-write access of a file mapping object after it has been created? ie., I want to map a file into memory, change it and without closing the mapping object want to view it (only) read-only. Is that possible?
Thanks.
|
|
|
|
|
Thank u for the answer!
cheerz!
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hi,
I need to start a program with errormode=SEM_NOALIGNMENTFAULTEXCEPT. I have made a small launcher program for this purpose. See here the code:
<br />
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT);<br />
PROCESS_INFORMATION pi;<br />
CreateProcess(TEXT("C:/app.exe"), NULL, NULL, NULL, false, 0, NULL, NULL, NULL, &pi);<br />
With this code starts the application app.exe, but i am not sure that it is runnend as child. It need to be a child, otherwise it doesn't use the right errorcode.
Do you know if i have done it right? If not, how can i start a application as child process? Or is there another way todo it?
Thank you.
Best regards,
Willem
|
|
|
|
|
What do you mean by "child process?" Once a process has been started, it is a process in its own right. Both processes are free to do what they will without affecting/impacting the other.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am developing an MFC application on the .NET compiler.
When I use atof function to convert a string to double value the compiler changes the decimal part of the result.
When I try to add two doubles the compiler does the same.
Below there is a simple example that I tried with the results I got:
example 1:
char str[11];
memset(str,0x00,11);
memcpy(str,"1234567.89",10);
double a = atof(str);
Output : a = 1234567.8899999999
--------------------------------
example 2
double a=1234567;
double b=0.89;
double d = a + b;
Output : a = 1234567.8899999999
Does anyone know why does this happen and what can I do to make it work properly?
Thanks in Advance
sirtimid
|
|
|
|
|
this is not a double problem ; it is a rounding one, known by the iso definition.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
|
I don't display it. I see it by the debugger.
|
|
|
|
|
there's not much you can do about it.
there's a book/paper about that :
"What Every Computer Scientist Should Know About Floating Point Arithmetic" by David Goldberg
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
I need to write an app, which could trap as soon as some Windows app of the
same computer sends a print job to the network printer server, add some data
to JOB_NOTIFY_FIELD_USER_NAME field of the print job, and then have continue
sending.
I only concern about the new print jobs sent from the computer which run
this app, other than all print queue of the network printer. It seems that
spooler APIs such as FindFirstPrinterChangeNotification, monitor all print
job in the queue.
Is there a simple way for me?
Thank you.
|
|
|
|
|
hello, in a singleton design, i trying to make my parent class having protected constructor and destructor. however, the compiler give me error when my child, trying to delete itself through parent pointer.
isn't child should have access to parent protected destructor?
thank you.
class CMachineFactory
{
protected:
CMachineFactory() {}
virtual ~CMachineFactory() {}
__________________________________________________________
CMachineFactory* CSemiAutoMachineFactory::m_pInstance = NULL;
class CSemiAutoMachineFactory : public CMachineFactory
{
protected:
CSemiAutoMachineFactory();
virtual ~CSemiAutoMachineFactory();
void CSemiAutoMachineFactory::DeleteInstance()
{
if(m_pInstance != NULL) {
delete m_pInstance; // Why not alowed. Isn't child is allowed
// to access parent's memeber?
m_pInstance = NULL;
}
}
E:\xxx\semiautomachinefactory.cpp(214) : error C2248: 'CMachineFactory::~CMachineFactory' : cannot access protected member declared in class 'CMachineFactory'
E:\Work\rd00072\ScanProxyEx\machinefactory.h(43) : see declaration of 'CMachineFactory::~CMachineFactory'
|
|
|
|
|
This is a non-compliant issue with VC++ compiler. The code should
compile, but it will not in VC++ 6.0 or 7.1.
As a workaround, you can create a friend class and let it delete your
singleton.
Here's a workaround example:
template<typename t="">
class Singleton
{
protected:
Singleton(){}
~Singleton(){}
Singleton(const Singleton&);
Singleton& operator=(const Singleton&);
public:
class FriendClass
{
public:
FriendClass():m_MyClass(new T()){}
~FriendClass(){delete m_MyClass;}
T* m_MyClass;
};
static T& Instance() {
static FriendClass Instance;
return *Instance.m_MyClass;
//Will not compile with the following code in VC++ 6.0 or 7.1
// static T Instance;
// return Instance;
}
};
//The above Singleton template can be used two ways.
//Either by deriving from it, or by declaring the friend class with
fully
//qualified template, and calling the instance member function with
fully
//qualified template function.
class Widget {
private:
Widget(){}
~Widget(){}
Widget& operator=(const Widget&);
Widget(const Widget&);
public:
friend class Singleton<widget>::FriendClass;
int m_i;
};
class foo : public Singleton<foo>{
private:
foo(){}
~foo(){}
foo& operator=(const foo&);
foo(const foo&);
public:
friend class FriendClass;
int m_i;
};
int main(int, char*)
{
Widget& MyWidget = Singleton<widget>::Instance();
foo& Myfoo = foo::Instance();
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
I developed one application which adds the icon to System tray. When I press Start (in menu) it will start.
But in our application ,.->
When I press 'X' in the dialog I don't want to terminate
the application .
When I press Shutdown (which is a menu item when I press on right click on icon )It has to shutdown.
Plz How to handle code in OnSysCommand ., When I press 'X'
in dialog.(Application Should not be terminate.Let it be there itself in the system tray )
Praveen Chowdam Kumar
|
|
|
|
|
|
parims wrote:
Plz How to handle code in OnSysCommand ., When I press 'X'
in dialog.(Application Should not be terminate.Let it be there itself in the system tray )
You have one more option :-
How to remove close button from window?[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi all
I have an application that creates a ms word document. I need to include the page number. I have posted a similar question last week but this one is more to the point.
I have done my research and according to msdn, the function to use is
expression.Add(PageNumberAlignment, FirstPage)
WdPageNumberAlignment
constants:
wdAlignPageNumberCenter, wdAlignPageNumberInside, wdAlignPageNumberLeft, wdAlignPageNumberOutside, or wdAlignPageNumberRight
I have no problem calling out the header and footer pop up... navigating between header and footer but I am still unable to add the page number. The above function uses the vb constants. Anyone know the c++ equivalent for these? I tried using it in C++ but its a undeclared identifier.
Thanks in advance.
Thomas
|
|
|
|
|
|
Barm wrote:
Anyone know the c++ equivalent for these?
wdAlignPageNumberLeft = 0
wdAlignPageNumberCenter = 1
wdAlignPageNumberRight = 2
wdAlignPageNumberInside = 3
wdAlignPageNumberOutside = 4
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I use Visual studio 6, and when I am debugging I can only see character pointers (char *), but for wchar_t pointers I only get the address in the watch/debug windows and I will have to check out the memory explicity. Is there any direct way of seeing the wide char strings during debugging?
thanks
|
|
|
|
|
You can see anything under:
View->Debug Windows->Memory
MS
|
|
|
|
|
Manfred Staiger wrote:
You can see anything under:
View->Debug Windows->Memory
Is that the only way to watch unicode variables? It is too much of work viewing a bunch of variables every time copy/pasting the memory location.
Or atleast, is there a way to open multiple memory windows to watch multiple variables?
|
|
|
|