home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / csapi / gmemory.api < prev    next >
Text File  |  1993-10-22  |  3KB  |  72 lines

  1. ' Global Memory Flags
  2. Global Const GMEM_FIXED = &H0
  3. Global Const GMEM_MOVEABLE = &H2
  4. Global Const GMEM_NOCOMPACT = &H10
  5. Global Const GMEM_NODISCARD = &H20
  6. Global Const GMEM_ZEROINIT = &H40
  7. Global Const GMEM_MODIFY = &H80
  8. Global Const GMEM_DISCARDABLE = &H100
  9. Global Const GMEM_NOT_BANKED = &H1000
  10. Global Const GMEM_SHARE = &H2000
  11. Global Const GMEM_DDESHARE = &H2000
  12. Global Const GMEM_NOTIFY = &H4000
  13. Global Const GMEM_LOWER = GMEM_NOT_BANKED
  14.  
  15. Global Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
  16. Global Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)
  17.  
  18. Declare Function GlobalAlloc Lib "Kernel" (ByVal wFlags As Integer, ByVal dwBytes As Long) As Integer
  19. Declare Function GlobalCompact Lib "Kernel" (ByVal dwMinFree As Long) As Long
  20. Declare Function GlobalFree Lib "Kernel" (ByVal hMem As Integer) As Integer
  21. Declare Function GlobalHandle Lib "Kernel" (ByVal wMem As Integer) As Long
  22. Declare Function GlobalLock Lib "Kernel" (ByVal hMem As Integer) As Long
  23. Declare Function GlobalReAlloc Lib "Kernel" (ByVal hMem As Integer, ByVal dwBytes As Long, ByVal wFlags As Integer) As Integer
  24.  
  25. 'NOTE: instead of declaring the function GlobalDiscard and calling
  26. '      GlobalDiscard(hMem), call GlobalReAlloc(hMem, 0, GMEM_MOVEABLE)
  27.  
  28. Declare Function GlobalSize Lib "Kernel" (ByVal hMem As Integer) As Long
  29. Declare Function GlobalUnlock Lib "Kernel" (ByVal hMem As Integer) As Integer
  30. Declare Function UnlockResource Lib "Kernel" Alias "GlobalUnlock" (ByVal hMem As Integer) As Integer
  31. Declare Function GlobalFlags Lib "Kernel" (ByVal hMem As Integer) As Integer
  32. Declare Function GlobalWire Lib "Kernel" (ByVal hMem As Integer) As Long
  33. Declare Function GlobalUnWire Lib "Kernel" (ByVal hMem As Integer) As Integer
  34. Declare Function GlobalUnlock Lib "Kernel" (ByVal hMem As Integer) As Integer
  35. Declare Function GlobalLRUNewest Lib "Kernel" (ByVal hMem As Integer) As Integer
  36. Declare Function GlobalLRUOldest Lib "Kernel" (ByVal hMem As Integer) As Integer
  37. Declare Function GlobalPageLock Lib "Kernel" (ByVal wSelector As Integer) As Integer
  38. Declare Function GlobalPageUnlock Lib "Kernel" (ByVal wSelector As Integer) As Integer
  39. Declare Sub GlobalFix Lib "Kernel" (ByVal hMem As Integer)
  40. Declare Function GlobalUnfix Lib "Kernel" (ByVal hMem As Integer) As Integer
  41.  
  42. ' Flags returned by GlobalFlags (in addition to GMEM_DISCARDABLE)
  43. Global Const GMEM_DISCARDED = &H4000
  44. Global Const GMEM_LOCKCOUNT = &HFF
  45.  
  46. Declare Function LockSegment Lib "Kernel" (ByVal wSegment As Integer) As Integer
  47. Declare Function UnlockSegment Lib "Kernel" (ByVal wSegment As Integer) As Integer
  48.  
  49. Declare Function lstrcpy Lib "Kernel" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
  50. Declare Sub hmemcpy Lib "kernel" (ByVal hpvDest As Any, ByVal hpvSource As Any, ByVal cbCopy As Long)
  51.  
  52. Function CreateGlobalBuffer (valueGlobalBuffer$, hGlobalBuffer%, lpszGlobalBuffer&, addrGlobalBuffer&) As Integer
  53.     
  54.     hGlobalBuffer% = GlobalAlloc(GHND, Len(valueGlobalBuffer$) + 1)
  55.     If hGlobalBuffer% <> 0 Then
  56.         lpszGlobalBuffer& = GlobalLock(hGlobalBuffer%)
  57.         If lpszGlobalBuffer& <> 0& Then
  58.             addrGlobalBuffer& = lstrcpy(lpszGlobalBuffer&, valueGlobalBuffer$)
  59.             CreateGlobalBuffer = True
  60.         End If
  61.     End If
  62.  
  63. End Function
  64.  
  65. Sub DestroyGlobalBuffer (hGlobalBuffer%)
  66.     
  67.     rci% = GlobalUnlock(hGlobalBuffer%)
  68.     rci% = GlobalFree(hGlobalBuffer%)
  69.  
  70. End Sub
  71.  
  72.