VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Creates a linked list using API calls for Quick and easy storage of large amounts of string/textual

Dave Cotton  (1 Submission)   Windows API Call/Explanation   VB 6.0   Unknown Difficulty   Fri 3rd May 2002   Mon 8th February 2021

Creates a linked list using API calls for Quick and easy storage of large amounts of string/textual data in VB dynamically. No problems with

API Declarations


'--------------------------------------
'Win32 API Constants
'--------------------------------------
Const GHND = &H42
'Same as combining GMEM_MOVEABLE with GMEM_ZEROINIT.
Const GMEM_DDESHARE = &H2000
'Optimize the allocated memory for use in DDE conversations.
Const GMEM_DISCARDABLE = &H100
'Allocate discardable memory. (Cannot be combined with GMEM_FIXED.)
Const GMEM_FIXED = &H0
'Allocate fixed memory. The function's return value is a pointer to the beginning of the memory block. (Cannot be combined with GMEM_DISCARDABLE or GMEM_MOVEABLE.)
Const GMEM_MOVEABLE = &H2
'Allocate moveable memory. The memory block's lock count is initialized at 0 (unlocked). The function's return value is a handle to the beginning of the memory block. (Cannot be combined with GMEM_FIXED.)
Const GMEM_NOCOMPACT = &H10
'Do not compact any memory or discard any discardable memory to allocate the requested block.
Const GMEM_NODISCARD = &H20
'Do not discard any discardable memory to allocate the requested block.
Const GMEM_SHARE = &H2000
'Same as GMEM_DDESHARE.
Const GMEM_ZEROINIT = &H40
'Initialize the contents of the memory block to 0.
Const GPTR = &H40
'Same as combining GMEM_FIXED with GMEM_ZEROINIT.

'List item looks like this:
'Size |Next |Data
'------|------|------
'4Bytes|4Bytes|nBytes
'
'Where Size is the size of the data EXCLUDING the Size and Next bytes.
'Next is a pointer to the next item in the list (or 0 if it is the last item).
'Data - the string to be stored. This is stored bytewise as ANSI text.
Const szPTR = 4
Const szSZ = 4
Const ptrOffSet = 4
Const szOffSet = 0
Const txtOffSet = 8

Private pLast As Long
Private pOffLast As Long
Private pBase As Long

Private lSize As Long

'--------------------------------------
'Win32 API functions
'--------------------------------------
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long



Rate Creates a linked list using API calls for Quick and easy storage of large amounts of string/textual (2(2 Vote))
Creates a linked list using API calls for Quick and easy storage of large amounts of string/textual.bas

Creates a linked list using API calls for Quick and easy storage of large amounts of string/textual Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters