dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] HeapQueryInformation & GetProcessHeaps

  1. #1

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    50

    Resolved [RESOLVED] HeapQueryInformation & GetProcessHeaps

    I need an example of using (HeapQueryInformation & GetProcessHeaps).
    I googled a lot but all i found is in C++ that i can't understand.

    Can somebody help please?

  2. #2
    Addicted Member
    Join Date
    Aug 2017
    Posts
    187

    Re: HeapQueryInformation & GetProcessHeaps

    Code:
    Option Explicit 'In a blank Form
    
    Private Enum HEAP_INFORMATION_CLASS
        HeapCompatibilityInformation = 0
        HeapEnableTerminationOnCorruption = 1
        HeapOptimizeResources = 3
    End Enum
    #If False Then
        Dim HeapCompatibilityInformation, HeapEnableTerminationOnCorruption, HeapOptimizeResources
    #End If
    
    Private Declare Function GetProcessHeaps Lib "kernel32.dll" (Optional ByVal NumberOfHeaps As Long, Optional ByRef ProcessHeaps As Long) As Long
    Private Declare Function HeapQueryInformation Lib "kernel32.dll" (ByVal HeapHandle As Long, ByVal HeapInformationClass As HEAP_INFORMATION_CLASS, ByRef HeapInformation As Any, ByVal HeapInformationLength As Long, Optional ByRef ReturnLength As Long) As Long
    
    Private Sub Form_Click()
        Dim hHeaps() As Long, HeapInfo As Long, I As Long
    
        ReDim hHeaps(1& To GetProcessHeaps) As Long
    
        Cls
        For I = 1& To GetProcessHeaps(UBound(hHeaps), hHeaps(1&))
            Print Format$(I, "@@@@\:"); "  &H"; Right$("0000" & Hex$(hHeaps(I)), 8&); " ";
    
            If HeapQueryInformation(hHeaps(I), HeapCompatibilityInformation, HeapInfo, 4&) Then
                Print HeapInfo
            Else
                Print "Err.LastDllError ="; Err.LastDllError
            End If
        Next
    End Sub
    
    Private Sub Form_Load()
        AutoRedraw = True
        On Error Resume Next
        FontName = "Consolas"
        FontSize = 10!
    End Sub
    Please refer to the documentations of GetProcessHeaps, HeapQueryInformation and HEAP_INFORMATION_CLASS to learn how to use those APIs.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2019
    Posts
    50

    Re: HeapQueryInformation & GetProcessHeaps

    Victor Bravo VI, Thank You Very Much, that is a very helpful example.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width