admin 管理员组文章数量: 1184232
2023年12月17日发(作者:git clones是什么意思)
{ if (m_Blint) { return ; } if (OrEmpty(sharedMemoryName)) { return rror; } if (memorySize <= 0 || memorySize > Memory_MaxSize) { memorySize = Memory_MaxSize; } m_Memsize = memorySize; //1.
创建内存共享体,存进字段 m_hSharedMemoryFile = CreateFileMapping(Invalib_Handle_value, , (uint)Page_Read_Write, 0, (uint)memorySize, sharedMemoryName); //2.
判断创建内存共享体是否成功 if (m_hSharedMemoryFile == ) { m_Blint = false; return ; } else { if (GetLatError() == Error_Alerady_Exists) //判断内存映射是否已经创建 { m_Blint = true; } } //3.
创建内存映射 m_pwData = MapViewOfFile(m_hSharedMemoryFile, File_Map_Write, 0, 0, (uint)memorySize); //4.
判断内存映射是否成功 if (m_pwData == ) { m_Blint = false; CloseHandle(m_hSharedMemoryFile); return ; } else { m_Blint = true; return ; } } catch (Exception ex) { throw ex; } finally { eMutex(); } } public void Close() { e(); if (m_Blint) { UnmapViewOfFile(m_pwData); CloseHandle(m_hSharedMemoryFile); } eMutex(); ();
版权声明:本文标题:C#共享内存技巧 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1702818992a432064.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论