Schnittstelle von TrySim, Pascal-Code

Top  Previous  Next

 

No english help available yet.

 

 

uses windows;

 

const  MaxAdr = $FFFF;

 

type   PAdrSpace = ^TAdrSpace;

        TAdrSpace = packed array [-MaxAdr..0] of Byte;

 

var EAdrSpace: PAdrSpace;

     AAdrSpace: PAdrSpace;

     MAdrSpace: PAdrSpace;

 

 

var hfile    : THandle;

 

{------------------------------------------------------------------------------}

function InitSchnittstelle: boolean;

 

const OutputOffset = 64 * 1024;

        InputOffset    = 64 * 1024 * 2;

        MerkerOffset = 64 * 1024 * 3;

        Length           = 64 * 1024;

 

var mappedname: PAnsiChar;

 

begin

 mappedname:= 'TRYSIM_SCHNITTSTELLE';

 hfile:= OpenFileMapping(FILE_MAP_ALL_ACCESS,

                                          FALSE,

                                          mappedname);

 

 if hfile = 0 then begin

    result:= false;

    EXIT;

 end;

 

AAdrSpace:=   MapViewOfFile(hfile,                                        // Handle to mapping object.

                                                   FILE_MAP_ALL_ACCESS,  // Read/write permission

                                                   0,                                             // Offset HiDWord

                                                   OutputOffset,                          // Offset LoDWord

                                                   Length);                                  // Size of View

 

 if AAdrSpace = nil then begin

   CloseSchnittstelle;

   result:= false;

   EXIT;

 end;

 

 EAdrSpace:=   MapViewOfFile(hfile,  // Handle to mapping object.

                                                  FILE_MAP_ALL_ACCESS,        // Read/write permission

                                                  0,                                                   // Offset HiDWord

                                                  InputOffset,                                   // Offset LoDWord

                                                  Length);                                        // Size of View

 

 if EAdrSpace = nil then begin

   CloseSchnittstelle;

   result:= false;

   EXIT;

 end;

 

MAdrSpace:=   MapViewOfFile(hfile,  // Handle to mapping object.

                                                  FILE_MAP_ALL_ACCESS,        // Read/write permission

                                                  0,                                                   // Offset HiDWord

                                                  MerkerOffset,                                // Offset LoDWord

                                                  Length);                                        // Size of View

 

 if MAdrSpace = nil then begin

   CloseSchnittstelle;

   result:= false;

   EXIT;

 end;

 

 result:= true;

end; { InitSchnittstelle }

{------------------------------------------------------------------------------}

procedure CloseSchnittstelle;

begin

 CloseHandle(hfile);

 hfile:= 0;

 AAdrSpace:= nil;

 EAdrSpace:= nil;

 MAdrSpace:= nil;

end; { CloseSchnittstelle }

{------------------------------------------------------------------------------}

 

Siehe auch:

Schnittstelle