Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

HeapCreate (kernel32)
 
.
Summary

Creates a private heap object that can be used by the calling process. The function reserves space in the virtual

address space of the process and allocates physical storage for a specified initial portion of this block.

C# Signature:

    /// <summary>
    /// HeapCreate - Creates a private heap object that can be used by the calling process.
    /// The function reserves space in the virtual address space of the process and allocates
    /// physical storage for a specified initial portion of this block.
    /// Ref: https://learn.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heapcreate
    /// </summary>
    /// <param name="flOptions"></param>
    /// <param name="dwInitialSize"></param>
    /// <param name="dwMaximumSize"></param>
    /// <returns></returns>
    [DllImport("kernel32.dll", SetLastError = true)]
    static extern IntPtr HeapCreate(UInt32 flOptions, UIntPtr dwInitialSize, UIntPtr dwMaximumSize);

User-Defined Types:

flOptions - https://pinvoke.net/default.aspx/Enums/flOptions.html

Notes:

Conversion of Int/Unit32/long/UIntPtr/IntPtr - much debate, this code could be checked properly.

Tips & Tricks:

Please add some!

Sample Code:

    /// <summary>
    /// HeapCreateMemory  - Creates a private heap object that can be used by the
    ///  calling process. The function reserves space in the virtual address space
    ///  of the process and allocates physical storage for a specified initial portion of this block.
    /// </summary>
    /// <param name="optionType"></param>
    /// <param name="initialbyteSize"></param>
    /// <param name="MaxByteSize"></param>
    /// <returns></returns>
    public static IntPtr HeapCreateMemory(FLOptionType optionType, int initialbyteSize, int MaxByteSize)
    {
      try
      {
    return HeapCreate((UInt32)optionType, (UIntPtr)initialbyteSize, (UIntPtr)MaxByteSize);
      }
      catch (Exception e)
      {
    throw e;
      }
    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
HeapCreate on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions