Hai,
I am new to this FileMapping Conepets.Please let me
help to solve this problem.This is very Urgent
I written one service and used the CreateFileMapping.
From CGI (C) application i try to use OpenFileMapping
which running in IIS4.0
But it is giving ERROR_ACCESS_DENIED error.
I know b’coz of securityattribute only it is giving
problem.But i don’t know how to set SecurityDescriptor
to this.
//Service CallBack function
DWORD ServiceThread(LPWORD param)
{
HANDLE fileHandle;
char *append;
HANDLE mapFileHandle;
char *timeline;
struct _timeb startTime;
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = 0;
fileHandle =
CreateFile(“D:\FileShare.txt”,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,&sa,OPEN_EXISTING,FILE_FLAG_WRITE_THROUGH,0);
if(fileHandle == INVALID_HANDLE_VALUE)
{
printf(“\nError”);
}
mapFileHandle =
CreateFileMapping(fileHandle,&sa,PAGE_READWRITE,0,sizeof(char)
* 20000,“FILESHARE”);
if(mapFileHandle <=0)
{
printf(“\nError1”);
}
append = (char
*)MapViewOfFile(mapFileHandle,FILE_MAP_ALL_ACCESS,0,0,0);
_ftime(&startTime);
timeline = ctime(&(startTime.time));
strcat(append,timeline);
if(FlushViewOfFile(append,sizeof(append)) < 0)
{
printf(“\nError”);
}
Sleep(60000);
}
//CGI Application running in IIS
HANDLE mapFileHandle;
struct _timeb startTime;
char *append;
char *timeline;
_ftime(&startTime);
mapFileHandle =
OpenFileMapping(FILE_MAP_ALL_ACCESS,TRUE,“FILESHARE”);
if(mapFileHandle <=0)
{
printf(“%d”,GetLastError());
printf(“\nError1”);
}
append = (char
*)MapViewOfFile(mapFileHandle,FILE_MAP_ALL_ACCESS,0,0,0);
timeline = ctime(&(startTime.time));
strcat(append,timeline);
printf(“%s”,append);
if(FlushViewOfFile(append,sizeof(append)) < 0)
{
printf(“\nError”);
}
cgimain(append);
if(!UnmapViewOfFile(append))
{
printf(“\nError”);
}
Please help me.This is very Urgent
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com