Problem with CreateFileMapping() function
Dear Experts,
i have a problem with CreateFileMapping() function ,
i am trying in this way,
Code:
hnd = (Mbyte*)CreateFile(fname, GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
printf("\n in if _hMap==============%d",(int)_hnd);//which gives me some 2060
_hMap = (char *)CreateFileMapping(_hnd,NULL,MAPPROTWRMODE,_fileSize,NULL);
printf("\n in if mapHandle==============%d",(int)_hmap);//which gives me NULL
why my map is getting failed when i can succesfully create a file,
i want the map for the file the "fname" specified in createfile please help me what can be the reason please provide me some solution.
Problem with creartedFilemapping
dear Experts,
sorry that i might have posted in the wrong forum,
but please tell me the solution to my problem,
if i remove the casts also the createFileMapping() is getting failed,
please tell me what is wrong because i used many examples to test ,
but there was not output please tell me what to do,
Code:
hnd = CreateFile(fname, GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
_hMap =CreateFileMapping(_hnd,NULL,MAPPROTWRMODE,_fileSize,NULL);
this _hmap is failing,what is wrong plz help me.
problem with CreateFileMapping()
Thank you for reply ,
i am using the getLastError() in this way
Code:
#define MAPPROTWRMODE PAGE_READWRITE
_hnd = CreateFile(fname, GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
_hMap =CreateFileMapping(_hnd,NULL,MAPPROTWRMODE,0,_fileSize,NULL);
register int errstat=0;
if(_hMap == NULL)
{
errstat=GetLastError();
if(errstat)
printf("\n ERROR* CreateFileMapping: error=%d\n",errstat);//which returns me 5 as number
}
i am using like this which gives me error=5 what does it mean ,
is it the right way i am using or any other way but does 5 indicates.
problem with CreateFileMapping()
Thank you experts thanks a lot,
thanks especially to tabstop who guessed the problem exactly, thanks to you specially,
the problem got solved , really very pleasurefull morning to me.