Archived

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

msvc - cant find function

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites