Before I describe my problem, here is an explanation of this program which I am writing:
This is a C ++ application.
The purpose of my program is to create a file on RAM memory.
I've read that specifying FILE_ATTRIBUTE_TEMPORARYI FILE_FLAG_DELETE_ON_CLOSE this RAM will be loaded directly into memory when creating the file.
A blog that talks about it is:
I have created a mini-program, but it has not been achieved. Instead, it creates a file on the hard drive on the specified directory.
Here is my program:
void main ()
{
LPCWSTR str = L " C: \ temp.txt "; Handle FH = CreateFile (str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (FH == INVALID_HANDLE_VALUE) {printf ("Could not open TWO.TXT"); Return; }
DWORD dwBytesWritten; (Lie Eye = 0; I & lt; 20000000; i ++) {WriteFile (FH, "This is a test for \ r \ n", 16, and dwBytesWritten, NULL)
} < / P>
return; }
I think there is a problem with the CreateFile function, but I can not fix it, please help me.
Larry Ostman also mentions:
If you have available memory , The memory manager will flush the file data into the disk. This affects a display, but your operation will succeed rather than fail.
Therefore, due to the limitation of memory the OS file creates the need to flush the data.
Comments
Post a Comment