public int Init(string strName) { if (strName.Length <= 0) { return(1); } this.m_hSharedMemoryFile = ZyShareMem.OpenFileMapping(6, false, strName); if (this.m_hSharedMemoryFile == IntPtr.Zero) { this.m_bAlreadyExist = false; this.m_bInit = false; return(2); } this.m_bAlreadyExist = true; this.m_pwData = ZyShareMem.MapViewOfFile(this.m_hSharedMemoryFile, 6u, 0u, 0u, 0u); this.m_pwDataWrite = this.m_pwData; this.m_pwDataRead = (IntPtr)(this.m_pwData.GetHashCode() + 50); if (this.m_pwData == IntPtr.Zero) { this.m_bInit = false; ZyShareMem.CloseHandle(this.m_hSharedMemoryFile); return(3); } this.m_bInit = true; this.SetSemaphore(); return(0); }
private void Close() { if (this.m_bInit) { ZyShareMem.UnmapViewOfFile(this.m_pwData); ZyShareMem.CloseHandle(this.m_hSharedMemoryFile); } }
private void Close() { if (this.hVoid != IntPtr.Zero) { ZyShareMem.UnmapViewOfFile(this.hVoid); this.hVoid = IntPtr.Zero; } if (this.hMappingHandle != IntPtr.Zero) { ZyShareMem.CloseHandle(this.hMappingHandle); this.hMappingHandle = IntPtr.Zero; } }