English
Regulars table & Café

GlobalAlloc.

 


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:

CompileMarkSeparation
Def 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

 
05/24/05  
 



salvo
 
05/24/05  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.418 Views

Untitledvor 0 min.
Ernst04/27/16
Michael Borowiak12/22/12

Themeninformationen

this Topic has 2 subscriber:

iF (1x)
unbekannt (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie