Updated: July 2009
Allocates memory from the process's unmanaged memory.
Namespace:
System.Runtime.InteropServices
Assembly:
mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
<SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.UnmanagedCode)> _
Public Shared Function AllocHGlobal ( _
cb As IntPtr _
) As IntPtr
Dim cb As IntPtr
Dim returnValue As IntPtr
returnValue = Marshal.AllocHGlobal(cb)
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static IntPtr AllocHGlobal(
IntPtr cb
)
[SecurityPermissionAttribute(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::UnmanagedCode)]
public:
static IntPtr AllocHGlobal(
IntPtr cb
)
public static function AllocHGlobal(
cb : IntPtr
) : IntPtr
AllocHGlobal is one of two memory allocation API methods in the Marshal class. (Marshal..::.AllocCoTaskMem is the other.) This method exposes the Win32 LocalAlloc function from Kernel32.dll.
When AllocHGlobal calls LocalAlloc, it passes a LMEM_FIXED flag, which causes the allocated memory to be locked in place. Also, the allocated memory is not zero-filled.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Reference
Date | History | Reason |
|---|
July 2009
| Enhanced Remarks section. |
Customer feedback.
|