Compartir a través de


Método Marshal.AllocCoTaskMem (Int32)

 

Publicado: octubre de 2016

Asigna un bloque de memoria de un tamaño especificado del asignador de memoria de tareas COM.

Espacio de nombres:   System.Runtime.InteropServices
Ensamblado:  mscorlib (en mscorlib.dll)

Sintaxis

[SecurityCriticalAttribute]
public static IntPtr AllocCoTaskMem(
    int cb
)
public:
[SecurityCriticalAttribute]
static IntPtr AllocCoTaskMem(
    int cb
)
[<SecurityCriticalAttribute>]
static member AllocCoTaskMem : 
        cb:int -> nativeint
<SecurityCriticalAttribute>
Public Shared Function AllocCoTaskMem (
    cb As Integer
) As IntPtr

Parámetros

  • cb
    Type: System.Int32

    Tamaño del bloque de memoria a asignar.

Valor devuelto

Type: System.IntPtr

Entero que representa la dirección del bloque de memoria asignado. Debe liberarse esta memoria con Marshal.FreeCoTaskMem.

Excepciones

Exception Condition
OutOfMemoryException

No hay memoria suficiente para satisfacer la solicitud.

Comentarios

AllocCoTaskMem is one of two memory allocation API methods in the Marshal class. (Marshal.AllocHGlobal is the other.) The initial memory content returned is undefined, and the allocated memory can be larger than the requested number of bytes. This method exposes the COM CoTaskMemAlloc function, which is referred to as the COM task memory allocator.

Seguridad

SecurityCriticalAttribute

requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Información de versión

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 1.1
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Windows Phone Silverlight
Disponible desde 8.0
Windows Phone
Disponible desde 8.1

Ver también

AllocHGlobal
FreeCoTaskMem
Clase Marshal
Espacio de nombres System.Runtime.InteropServices

Volver al principio