Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public void Close()
 {
     try
     {
         if (this.existed)
         {
             MemoryShare.UnmapViewOfFile(this.m_pwData);
             MemoryShare.CloseHandle(this.fileHanlder);
             this.existed = false;
         }
     }
     catch (System.Exception)
     {
     }
 }