public int Create() { this.fileHanlder = MemoryShare.CreateFileMapping(-1, System.IntPtr.Zero, 4u, 0u, (uint)this.memorySize, this.name); if (this.fileHanlder == System.IntPtr.Zero) { this.existed = false; return(0); } if (MemoryShare.GetLastError() == 183) { this.existed = true; } else { this.existed = false; } if (!this.existed) { this.m_pwData = MemoryShare.MapViewOfFile(this.fileHanlder, 2u, 0u, 0u, (uint)this.memorySize); if (this.m_pwData == System.IntPtr.Zero) { MemoryShare.CloseHandle(this.fileHanlder); return(0); } this.existed = true; } return(1); }
public void Close() { try { if (this.existed) { MemoryShare.UnmapViewOfFile(this.m_pwData); MemoryShare.CloseHandle(this.fileHanlder); this.existed = false; } } catch (System.Exception) { } }
private int open() { this.fileHanlder = MemoryShare.OpenFileMapping(4, false, this.name); if (this.fileHanlder == System.IntPtr.Zero) { MemoryShare.GetLastError(); return(0); } this.existed = true; this.m_pwData = MemoryShare.MapViewOfFile(this.fileHanlder, 4u, 0u, 0u, (uint)this.memorySize); if (this.m_pwData == System.IntPtr.Zero) { MemoryShare.GetLastError(); return(0); } return(1); }