msvc - cant find function

Started by
3 comments, last by logout 20 years ago
The problem comes when i try to compile using the function: CreateFileForMapping() So where is this function defined ? I currently include: windows.h Winbase.h // msdn say that CreateFileForMapping is defined here stdio.h any help would be ok
Advertisement
This is very likely relateed to an error in the code that has confused the compiler.

Can we see the relevant lines?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Im just testing out mmapping so here is the entire source as it is:


#include <windows.h>#include <stdio.h>#include <stdio.h>#include <iostream>using namespace std;void main(){	HANDLE hFile = NULL;	hFile = CreateFileForMapping( "test_file.txt", GENERIC_WRITE | GENERIC_READ,								  0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,								  FILE_FLAG_RANDOM_ACCESS );	if( hFile )		cout << "CreateFileForMapping - ok" << endl;	else		return;	hFile = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,5, "test.txt" );	if( hFile )		cout << "CreateFileMapping - ok" << endl;	else		return;	char* file = (char*)MapViewOfFile( hFile, FILE_MAP_WRITE, 0, 0, 0 );	if( file == NULL )	{		cout << "MapViewOfFile - fail" << endl;		return;	}	cout << "file: " << file << endl;	UnmapViewOfFile( file );}
CreateFileForMapping() appears to only be available for windwos CE. Assuming you knew this from MSDN it does not look like you can set the desired access to GENERIC_WRITE as you are only allowed read-only access.

-Dan
I just ran into this myself. Maybe late for you, maybe not...

The MSDN subscription is pretty lowsy in not telling you that for anything other than Windows CE just use CreateFile( ) and the file it returns can be passed to CreateFileMapping( )

After bashing my head there and on the net and then ultimately finding this thread I tried CreateFile( ) and when I talked to a buddy at work in the morning, the one to suggest using this method, he knew to call CreateFile( ) and that the CreateFileForMapping( ) is a CE only- ARRRGGGHHH

-Neil

This topic is closed to new replies.

Advertisement