#### Archived

This topic is now archived and is closed to further replies.

# msvc - cant find function

This topic is 5249 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
This is very likely relateed to an error in the code that has confused the compiler.

Can we see the relevant lines?

##### Share on other sites
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 );}

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
frob
15
3. 3
4. 4
Rutin
12
5. 5

• 12
• 12
• 58
• 14
• 15
• ### Forum Statistics

• Total Topics
632115
• Total Posts
3004196

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!