MemoryMappedFile.OpenExisting Yöntem

Tanım

Sistem belleğinde mevcut adlandırılmış belleğe eşlenmiş bir dosyayı açar.

Aşırı Yüklemeler

Name Description
OpenExisting(String)

Sistem belleğinde belirtilen ada sahip, bellekle eşlenmiş mevcut bir dosyayı açar.

OpenExisting(String, MemoryMappedFileRights)

Sistem belleğinde belirtilen ada ve erişim haklarına sahip, bellekle eşlenen mevcut bir dosyayı açar.

OpenExisting(String, MemoryMappedFileRights, HandleInheritability)

Sistem belleğinde belirtilen ada, erişim haklarına ve devralınabilirliğe sahip, bellekle eşlenen mevcut bir dosyayı açar.

OpenExisting(String)

Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs

Sistem belleğinde belirtilen ada sahip, bellekle eşlenmiş mevcut bir dosyayı açar.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ OpenExisting(System::String ^ mapName);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName);
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member OpenExisting : string -> System.IO.MemoryMappedFiles.MemoryMappedFile
static member OpenExisting : string -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function OpenExisting (mapName As String) As MemoryMappedFile

Parametreler

mapName
String

Bellekle eşlenen dosyanın adı.

Döndürülenler

Belirtilen ada sahip bellek eşlemeli bir dosya.

Öznitelikler

Özel durumlar

mapName, null'e eşittir.

mapName boş bir dizedir.

için mapName belirtilen dosya yok.

Örnekler

Kalıcı Memory-Mapped Dosyasını Açma

Aşağıdaki örnek, diskteki bir dosyadan zaten oluşturulmuş olan adlı ImgA belleğe eşlenmiş bir dosya açar (yöntem örneğinde CreateFromFile(String) gösterildiği gibi).

using System;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;

class Program
{
    static void Main(string[] args)
    {
        // Assumes another process has created the memory-mapped file.
        using (var mmf = MemoryMappedFile.OpenExisting("ImgA"))
        {
            using (var accessor = mmf.CreateViewAccessor(4000000, 2000000))
            {
                int colorSize = Marshal.SizeOf(typeof(MyColor));
                MyColor color;

                // Make changes to the view.
                for (long i = 0; i < 1500000; i += colorSize)
                {
                    accessor.Read(i, out color);
                    color.Brighten(20);
                    accessor.Write(i, ref color);
                }
            }
        }
    }
}

public struct MyColor
{
    public short Red;
    public short Green;
    public short Blue;
    public short Alpha;

    // Make the view brigher.
    public void Brighten(short value)
    {
        Red = (short)Math.Min(short.MaxValue, (int)Red + value);
        Green = (short)Math.Min(short.MaxValue, (int)Green + value);
        Blue = (short)Math.Min(short.MaxValue, (int)Blue + value);
        Alpha = (short)Math.Min(short.MaxValue, (int)Alpha + value);
    }
}
Imports System.IO.MemoryMappedFiles
Imports System.Runtime.InteropServices

Class Program
    Public Shared Sub Main(ByVal args As String())
        ' Assumes another process has created the memory-mapped file.
        Using mmf = MemoryMappedFile.OpenExisting("ImgA")
            Using accessor = mmf.CreateViewAccessor(4000000, 2000000)
                Dim colorSize As Integer = Marshal.SizeOf(GetType(MyColor))
                Dim color As MyColor

                ' Make changes to the view.
                Dim i As Long = 0
                While i < 1500000
                    accessor.Read(i, color)
                    color.Brighten(30)
                    accessor.Write(i, color)
                    i += colorSize
                End While
            End Using
        End Using
    End Sub
End Class

Public Structure MyColor
    Public Red As Short
    Public Green As Short
    Public Blue As Short
    Public Alpha As Short

    ' Make the view brigher.
    Public Sub Brighten(ByVal value As Short)
        Red = CShort(Math.Min(Short.MaxValue, CInt(Red) + value))
        Green = CShort(Math.Min(Short.MaxValue, CInt(Green) + value))
        Blue = CShort(Math.Min(Short.MaxValue, CInt(Blue) + value))
        Alpha = CShort(Math.Min(Short.MaxValue, CInt(Alpha) + value))
    End Sub
End Structure

Kalıcı Olmayan Memory-Mapped Dosyası Açma

Aşağıdaki örnek, işlemler arası iletişim için kullanılan belleğe eşlenmiş bir dosya açar. Bu kod örneği, yöntemi için CreateNew(String, Int64) sağlanan daha büyük bir örneğin parçasıdır.

Açıklamalar

Bellekle eşlenen dosya kalıcı bellek eşlemeli bir dosya (disk üzerindeki bir dosyayla ilişkili) veya kalıcı olmayan bir dosya olabilir.

Ayrıca bkz.

Şunlara uygulanır

OpenExisting(String, MemoryMappedFileRights)

Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs

Sistem belleğinde belirtilen ada ve erişim haklarına sahip, bellekle eşlenen mevcut bir dosyayı açar.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ OpenExisting(System::String ^ mapName, System::IO::MemoryMappedFiles::MemoryMappedFileRights desiredAccessRights);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights);
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member OpenExisting : string * System.IO.MemoryMappedFiles.MemoryMappedFileRights -> System.IO.MemoryMappedFiles.MemoryMappedFile
static member OpenExisting : string * System.IO.MemoryMappedFiles.MemoryMappedFileRights -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function OpenExisting (mapName As String, desiredAccessRights As MemoryMappedFileRights) As MemoryMappedFile

Parametreler

mapName
String

Açılacak bellekle eşlenen dosyanın adı.

desiredAccessRights
MemoryMappedFileRights

Bellekle eşlenen dosyaya uygulanacak erişim haklarını belirten numaralandırma değerlerinden biri.

Döndürülenler

Belirtilen özelliklere sahip belleğe eşlenmiş bir dosya.

Öznitelikler

Özel durumlar

mapName, null'e eşittir.

mapName boş bir dizedir.

desiredAccessRights geçerli MemoryMappedFileRights bir numaralandırma değeri değildir.

için mapName belirtilen dosya yok.

Ayrıca bkz.

Şunlara uygulanır

OpenExisting(String, MemoryMappedFileRights, HandleInheritability)

Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs
Kaynak:
MemoryMappedFile.cs

Sistem belleğinde belirtilen ada, erişim haklarına ve devralınabilirliğe sahip, bellekle eşlenen mevcut bir dosyayı açar.

public:
 static System::IO::MemoryMappedFiles::MemoryMappedFile ^ OpenExisting(System::String ^ mapName, System::IO::MemoryMappedFiles::MemoryMappedFileRights desiredAccessRights, System::IO::HandleInheritability inheritability);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights, System.IO.HandleInheritability inheritability);
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights, System.IO.HandleInheritability inheritability);
[System.Security.SecurityCritical]
public static System.IO.MemoryMappedFiles.MemoryMappedFile OpenExisting(string mapName, System.IO.MemoryMappedFiles.MemoryMappedFileRights desiredAccessRights, System.IO.HandleInheritability inheritability);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member OpenExisting : string * System.IO.MemoryMappedFiles.MemoryMappedFileRights * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
static member OpenExisting : string * System.IO.MemoryMappedFiles.MemoryMappedFileRights * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
[<System.Security.SecurityCritical>]
static member OpenExisting : string * System.IO.MemoryMappedFiles.MemoryMappedFileRights * System.IO.HandleInheritability -> System.IO.MemoryMappedFiles.MemoryMappedFile
Public Shared Function OpenExisting (mapName As String, desiredAccessRights As MemoryMappedFileRights, inheritability As HandleInheritability) As MemoryMappedFile

Parametreler

mapName
String

Açılacak bellekle eşlenen dosyanın adı.

desiredAccessRights
MemoryMappedFileRights

Bellekle eşlenen dosyaya uygulanacak erişim haklarını belirten numaralandırma değerlerinden biri.

inheritability
HandleInheritability

Bellek eşlemeli dosya tanıtıcısının bir alt işlem tarafından devralınıp devralınamayacağını belirten numaralandırma değerlerinden biri. Varsayılan değer: None.

Döndürülenler

Belirtilen özelliklere sahip belleğe eşlenmiş bir dosya.

Öznitelikler

Özel durumlar

mapName, null'e eşittir.

mapName boş bir dizedir.

desiredAccessRights geçerli MemoryMappedFileRights bir numaralandırma değeri değildir.

-veya-

inheritability geçerli HandleInheritability bir numaralandırma değeri değildir.

İstenen erişim, bellekle eşlenen dosya için geçersiz.

için mapName belirtilen dosya yok.

Ayrıca bkz.

Şunlara uygulanır