I seem have a few problems returning a reference to a shared memory location and keep on getting a run time at the specified location below...
this is the code
class function TActivityLogger.NewInstance: TObject;
var
llInit:Boolean;
temp:LoggerPointer;
begin
HMapping:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,MAPFILESIZE,pchar('my mem'));
...
llInit:=(getLastError()<>ERROR_ALREADY_EXISTS);
if ( llInit ) then //first instance
begin
temp:=mapViewOfFile(HMapping,fILE_MAP_all_access,0,0,0);
....
Result:=temp^.instance ;
end
else
begin
HMapping:=openfilemapping( FILE_MAP_all_access,true, pchar('my mem'));
...
temp:=MapViewOfFile(HMapping,FILE_MAP_all_access,0,0,0);
...
Result:=temp^.instance;//<-Runtime error occurs here
end;
end;
this is the code
class function TActivityLogger.NewInstance: TObject;
var
llInit:Boolean;
temp:LoggerPointer;
begin
HMapping:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,MAPFILESIZE,pchar('my mem'));
...
llInit:=(getLastError()<>ERROR_ALREADY_EXISTS);
if ( llInit ) then //first instance
begin
temp:=mapViewOfFile(HMapping,fILE_MAP_all_access,0,0,0);
....
Result:=temp^.instance ;
end
else
begin
HMapping:=openfilemapping( FILE_MAP_all_access,true, pchar('my mem'));
...
temp:=MapViewOfFile(HMapping,FILE_MAP_all_access,0,0,0);
...
Result:=temp^.instance;//<-Runtime error occurs here
end;
end;