| |
|
|
| Description:
OpenFileMapping opens one with CreateFileMapping erzeugtes benanntes Filemapping Objekt and supply which lever back.
Deklaration:
DEF @OpenFileMapping(3) !kernel32,OpenFileMappingA
Parameter:
1.Parameter: One Flag for Zugriffsmodus the lever. -$2 = only reading. -$4 = write and reading. -$8 = reading and write, but not The disk. under NT-based Systemen write only actually Process. 2.Parameter: One Flag, the specify, whether the zurückgegebene lever on others processes vererbt go can. => -1 = can vererbt go. -0 = can't vererbt go. 3.Parameter: One String or a Memory-Variable with a String, the whom names the To öffnenden Dateiabbildungsprojektes contains.
Return Value:
0 with failure, otherwise the lever the Dateiabbildungsprojektes.
Examples:
example 1
DEF @CopyMemory(3) !kernel32,RtlMoveMemory
DEF @CreateFileMapping(6) !kernel32,CreateFileMappingA
Def @CloseHandle(1) !kernel32,CloseHandle
DEF @GetLastError() !kernel32,GetLastError
DEF @WriteFile(5) !kernel32,WriteFile
Def @MapViewOfFile(5) !kernel32,MapViewOfFile
DEf @UnmapViewOfFile(1) !kernel32,UnmapViewOfFile
DEF @CopyMemory(3) !kernel32,RtlMoveMemory
DEF @CreateFile(7) !kernel32,CreateFileA
WINDOWSTYLE 31+512
Windowtitle here becomes The Variable created
WINDOW 0,0-300,400
Declare Tick&,name$,Ausgelesen#
Declare Speicherhandle&,Speicheraddr&,Dateihandle&
Declare Dateiname$,Text$,Written#,Dateilänge&
LET TEXT$=From the 1.File written
LET DATEINAME$=C:TEST.TXT
LET DateiHandle&=@CreateFile(@ADDR(Dateiname$),$80000000+$40000000,0,0,4,$80,0)
Dim Written#,4
@WriteFile(DateiHandle&,@ADDR(TEXT$),@len(Text$),Written#,0)
Dispose Written#
Let name$=AH-File
LET Speicherhandle&=@CreateFileMapping(DateiHandle&,0,4,0,0,@addr(name$))
DrawText 0,50,lever the Speicherbereichs: +@STR$(Speicherhandle&)
LET Speicheraddr&=@MapViewOfFile(Speicherhandle&,2,0,0,0)
Whilenot %MENUITEM=-2
IF &GETTICKCOUNT-Tick&>10000
@CopyMemory(Speicheraddr&,@addr(Text$),@len(Text$))
LET TICK&=&GETTICKCOUNT
endif
DIM Ausgelesen#,256
Clear Ausgelesen#
@CopyMemory(Ausgelesen#,Speicheraddr&,@len(Text$))
DrawText 0,80,Text=+@String $(Ausgelesen#,0)+
Dispose Ausgelesen#
Sleep 10
WEND
@CloseHandle(Speicherhandle&)
@CloseHandle(DateiHandle&)
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 here becomes The Variable read
WINDOWSTYLE 31+512
WINDOW 300,0-300,400
Declare Speicherhandle&,Ausgelesen#,name$
Declare Speicheraddr&,Text$
Declare Variable&
Let Text$=From the 2.File written
Let name$=AH-File
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,lever the Speicherbereichs:+@STR$(Speicherhandle&)
DIM Ausgelesen#,256
Clear Ausgelesen#
WHILEnot %MENUITEM=-2
DrawText 0,0,F1 pressing to that Reading
DrawText 0,21,F2 pressing to that write...
Waitinput
IF %SCANKEY=112
@CopyMemory(Ausgelesen#,Speicheraddr&,@len(Text$))
DrawText 0,80,Variale=+@String $(Ausgelesen#,0)+
Beep 1
ElseIF %SCANKEY=113
Beep 1
@CopyMemory(Speicheraddr&,@addr(Text$),@len(Text$))
@CopyMemory(Ausgelesen#,Speicheraddr&,@len(Text$))
DrawText 0,80,Variale=+@String $(Ausgelesen#,0)+
Endif
WEND
Dispose Ausgelesen#
@UnmapViewOfFile(Speicheraddr&)
@CloseHandle(Speicherhandle&)
Beep 1
|
|
|
| |
|
|