Delen via


MemoryBuffer Class

Definition

Represents a reference counted memory buffer.

public ref class MemoryBuffer sealed : IClosable, IMemoryBuffer
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.IMemoryBufferFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class MemoryBuffer final : IClosable, IMemoryBuffer
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.IMemoryBufferFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class MemoryBuffer final : IClosable, IMemoryBuffer
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.IMemoryBufferFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class MemoryBuffer : System.IDisposable, IMemoryBuffer
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.IMemoryBufferFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class MemoryBuffer : System.IDisposable, IMemoryBuffer
function MemoryBuffer(capacity)
Public NotInheritable Class MemoryBuffer
Implements IDisposable, IMemoryBuffer
Inheritance
Object Platform::Object IInspectable MemoryBuffer
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

This type also implements the COM interface IMemoryBufferByteAccess, which provides direct access to the buffer's storage. See the Custom Effect sample for a C# example on how to access the buffer.

Note

C++/WinRT provides extension methods on MemoryBuffer to access the data directly. Various languages and runtimes provide unique ways to access process memory. Be careful when accessing the buffer as the lifecycle of the memory is related to the lifecycle of the IMemoryBufferByteAccess interface.

Constructors

MemoryBuffer(UInt32)

Initializes a new MemoryBuffer instance with the specified capacity.

Methods

Close()

Disconnects this MemoryBuffer object from the actual memory buffer.

CreateReference()

Returns a new managed object that implements the IMemoryBufferReference interface.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Applies to

See also