| |
|
|
|
Description:
Alloziert a Speicherblock from the Heap
Deklaration:
Def GlobalAlloc(2) !kernel32, GlobalAlloc
Parameter:
1.Parameter: an combination following Konstanten: ~GMEM_FIXED = $0, can't with ~GMEM_MOVEABLE or ~GMEM_DISCARDABLE combined go
~GMEM_MOVEABLE = $2, can't with ~GMEM_FIXED combined go
~GPTR = $40 ~GHND = $42 ~GMEM_DDESHARE = $2000 ~GMEM_DISCARDABLE = $100, can't with ~GMEM_FIXED combined go
~GMEM_NOCOMPACT = $10 ~GMEM_NODISCARD = $20 ~GMEM_SHARE = $2000 ~GMEM_ZEROINIT = $40, Initialisiert whom Speicherinhalt with zero
2.Parameter: Size& (Size the Speichers in byte)
Return Value:
in the Fehlerfalle 0, otherwise lever the allozierten Speicherobjekts
example:
CompileMarkSeparationDef GlobalAlloc(2) !KERNEL32.DLL, GlobalAlloc
Def GlobalFree(1) !KERNEL32.DLL, GlobalFree
Def MoveMemory(3) !KERNEL32, RtlMoveMemory
Proc PeekL
Parameters ReadMemoryAddr&
Declare Value&, Result!
MoveMemory(Addr(Value&), ReadMemoryAddr& + 2, 2)
Result! = Value& * 2^16
MoveMemory(Addr(Value&), ReadMemoryAddr&, 2)
Result! = Result! + Value&
Return Result!
EndProc
Proc PokeL
Parameters WriteMemoryAddr&, Value!
Declare Value&
If (Value! > -1) And (Value! < 2^32)
If Value! - (2^16 - 1) > 0
Value& = Value! 2^16
Else
Value& = 0
EndIf
MoveMemory(WriteMemoryAddr& + 2, @Addr(Value&), 2)
Value& = Int(Value! - (Value& * 2^16))
MoveMemory(WriteMemoryAddr&, Addr(Value&), 2)
Else
MessageBox(Zahl zu groß!, Wichtiger Hinweis, 48)
EndIf
EndProc
Declare hMem&
4 Byte = Long Speicher reservieren
hMem& = GlobalAlloc($40, 4)
If hMem&
Speicher mit 1111 füllen
PokeL hMem&, 1111
Speicher auslesen und in MessageBox wiedergeben
MessageBox(In Adresse: + Str$(hMem&) + steht folgender Wert: + Str$(Int(PeekL(hMem&))) , Inhalt des Speicher, 0)
Speicherobjekt freigeben
GlobalFree(hMem&)
Else
MessageBox(Speicher konnte nicht reserviert werden, Wichtiger Hinweis, 48)
href='./../Function-References/XProfan/endif/'>EndIf
GlobalLock, GlobalReAlloc, GlobalFree
|
|
|
| |
|
|
|
| |
|
| |
|
|