| |
|
|
|
Description:
MapViewOfFile forms one (with CreateFileMapping erzeugtes or OpenFileMapping geöffnetes) Dateiabbildungsprojekt in the Speicherbereich the aufrufenden Prozesses ex and supply a Anfangsadresse back.
Deklaration:
Def @MapViewOfFile(5) !kernel32,MapViewOfFile
Parameter:
1.Parameter: lever the with CreateFileMapping begot Dateiabbildungsprojektes as LongInt. 2.Parameter: One Flag Zugriffsmodus on the Speicherbereich. => -$2 = Schreib- and Lesezugriff. -$4 = only Lesezugriff. -$000F001F = Schreib- and Lesezugriff (How $2) -$1 = under NT-based Windowsversionen find Changes the File only Speicherbereich the current Prozesses instead of – on The disk and Abbildungen another processes becomes nothing written. under not NT-based Systemen becomes of course too the Mappingbereich another processes changed, The File the disk changes itself but not. 3.Parameter: The oberen 32 Bits the Startadresse the with CreateFileMapping begot Speicherbereichs, ex the the Mapping begin should. 4.Parameter: The downstairs 32 Bits the Startadresse the with CreateFileMapping begot Speicherbereichs, ex the the Mapping begin should. 5.Parameter: Number of To übertragenden Bytes as LongInt.
Return Value:
0 with failure, otherwise The Startadresse the Speicherbereichs.
Examples:
example 1
DEF @CopyMemory(3) !"kernel32","RtlMoveMemory"
DEF @CreateFileMapping(6) !"kernel32","CreateFileMappingA"
Def @CloseHandle(1) !"kernel32","CloseHandle"
DEF @GetLastError() !"kernel32","GetLastError"
Def @MapViewOfFile(5) !"kernel32","MapViewOfFile"
DEf @UnmapViewOfFile(1) !"kernel32","UnmapViewOfFile"
DEF @CopyMemory(3) !"kernel32","RtlMoveMemory"
WINDOWSTYLE 31+512
Windowtitle "Hier becomes The Variable erzeugt"
WINDOW 0,0-300,400
Declare Variable&,Tick&,name$,Ausgelesen#
Declare Speicherhandle&,Speicheraddr&
Let name$="AH-Variable"
LET Speicherhandle&=@CreateFileMapping($FFFFFFFF,0,4,0,4,@addr(name$))
LET Speicheraddr&=@MapViewOfFile(Speicherhandle&,2,0,0,0)
DrawText 0,50,"Handle the Speicherbereichs:"+@STR$(Speicherhandle&)
LET TICK&=&GETTICKCOUNT
Whilenot %MENUITEM=-2
IF &GETTICKCOUNT-Tick&>10000
Let Variable&=@RND(1000)
@CopyMemory(Speicheraddr&,@addr(Variable&),4)
LET TICK&=&GETTICKCOUNT
endif
DIM Ausgelesen#,256
@CopyMemory(Ausgelesen#,Speicheraddr&,4)
DrawText 0,80,"Variale="+@STR$(@LONG(Ausgelesen#,0))+" "
Dispose Ausgelesen#
Sleep 10
WEND
@UnmapViewOfFile(Speicheraddr&)
@CloseHandle(Speicherhandle&)
Beep 1
DEF @OpenFileMapping(3) !"kernel32","OpenFileMappingA"
DEF @GetLastError() !"kernel32","GetLastError"
Def @MapViewOfFile(5) !"kernel32","MapViewOfFile"
DEf @UnmapViewOfFile(1) !"kernel32","UnmapViewOfFile"
DEF @CopyMemory(3) !"kernel32","RtlMoveMemory"
Def @CloseHandle(1) !"kernel32","CloseHandle"
Windowtitle "Hier becomes The Variable ausgelesen"
WINDOWSTYLE 31+512
WINDOW 300,0-300,400
Declare Speicherhandle&,Ausgelesen#,name$
Declare Speicheraddr&
Declare Variable&
Let Variable&=0
Let name$="AH-Variable"
While @AND(Speicherhandle&=0,%MENUITEM<>-2)
sleep 100
LET Speicherhandle&=@OpenFileMapping(2,0,@ADDR(name$))
Wend
LET Speicherhandle&=@OpenFileMapping(2,0,@ADDR(name$))
LET Speicheraddr&=@MapViewOfFile(Speicherhandle&,2,0,0,0)
DrawText 0,50,"Handle the Speicherbereichs:"+@STR$(Speicherhandle&)
DIM Ausgelesen#,256
WHILEnot %MENUITEM=-2
DrawText 0,0,"F1 pressing to that Auslesen"
DrawText 0,21,"F2 pressing to that Zurücksetzen..."
Waitinput
IF %SCANKEY=112
@CopyMemory(Ausgelesen#,Speicheraddr&,4)
DrawText 0,80,"Variale="+@STR$(@LONG(Ausgelesen#,0))+" "
Beep 1
ElseIF %SCANKEY=113
Beep 1
@CopyMemory(Speicheraddr&,@addr(Variable&),4)
@CopyMemory(Ausgelesen#,Speicheraddr&,4)
DrawText 0,80,"Variale="+@STR$(@LONG(Ausgelesen#,0))+" "
Endif
WEND
Dispose Ausgelesen#
@UnmapViewOfFile(Speicheraddr&)
@CloseHandle(Speicherhandle&)
Beep 1
|
|
|
| |
|
|