SafeBuffer.AcquirePointer(Byte*) SafeBuffer.AcquirePointer(Byte*) SafeBuffer.AcquirePointer(Byte*) Method

Definición

Importante

Esta API no es conforme a CLS.

Obtiene un puntero de un objeto SafeBuffer para un bloque de memoria.Obtains a pointer from a SafeBuffer object for a block of memory.

public:
 void AcquirePointer(System::Byte* % pointer);
[System.CLSCompliant(false)]
public void AcquirePointer (ref byte* pointer);
member this.AcquirePointer : Byte* -> unit

Parámetros

pointer
Byte*

Puntero de byte, pasado por referencia, para recibir el puntero desde dentro del objeto SafeBuffer.A byte pointer, passed by reference, to receive the pointer from within the SafeBuffer object. Debe establecer este puntero en null antes de llamar a este método.You must set this pointer to null before you call this method.

Excepciones

No se ha llamado al método Initialize.The Initialize method has not been called.

Comentarios

Cuando AcquirePointer devuelve, debe realizar la comprobación de los límites comprobando que el pointer parámetro es null.When AcquirePointer returns, you should perform bounds checking by verifying that the pointer parameter is null. Si no nulles así, debe llamar al SafeBuffer.ReleasePointer método en una región de ejecución restringida (CER).If it is not null, you must call the SafeBuffer.ReleasePointer method in a constrained execution region (CER).

AcquirePointerllama al SafeHandle.DangerousAddRef método y expone el puntero.AcquirePointer calls the SafeHandle.DangerousAddRef method and exposes the pointer. A diferencia del Read método, no cambia la posición actual del puntero.Unlike the Read method, it does not change the current position of the pointer.

En el ejemplo siguiente se muestra cómo usar AcquirePointer el método:The following example demonstrates how to use the AcquirePointer method:

byte* pointer = null;  
RuntimeHelpers.PrepareConstrainedRegions();  
try {  
    MySafeBuffer.AcquirePointer(ref pointer);  
    // Use pointer here, with your own bounds checking.  
    }  
finally {  
    if (pointer != null)  
        MySafeBuffer.ReleasePointer();  
    }  

Si convierte pointer (que es un puntero a un byte) como un puntero a un tipo diferente (T *), puede tener problemas de alineación de punteros.If you cast pointer (which is a pointer to a byte) as a pointer to a different type (T*), you may have pointer alignment issues.

Debe asumir la responsabilidad de todas las comprobaciones de los límites con este puntero.You must take responsibility for all bounds checking with this pointer.

Se aplica a