WEB开发网
开发学院软件开发VC 共享内存封装类 阅读

共享内存封装类

 2006-07-19 11:35:35 来源:WEB开发网   
核心提示: 2002/07/05// awzzz// SFMMem.h: interface for the CSFMServer class.//#if !defined(AFX_SFMSERVER_H__2D76A439_6388_4B07_AE7A_C82F458642ED__INCLUDED

//------------------------------------------------

// 2002/07/05

// awzzz

// SFMMem.h: interface for the CSFMServer class.

//------------------------------------------------

#if !defined(AFX_SFMSERVER_H__2D76A439_6388_4B07_AE7A_C82F458642ED__INCLUDED_)
#define AFX_SFMSERVER_H__2D76A439_6388_4B07_AE7A_C82F458642ED__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define  DEFAULT_FILENAME  NULL
#define  DEFAULT_MAPNAME    "_SFM_OBJ_"
#define  DEFAULT_MAPSIZE    (0xFFFF + 1)

// Shared FileMap Server

class CSFMServer 
{
public:
  CSFMServer();
  virtual ~CSFMServer();
  CSFMServer(char *szFileName, char *szMapName, DWORD dwSize);
protected:
  HANDLE  m_hFile;
  HANDLE  m_hFileMap;
  LPVOID  m_lpFileMapBuffer;
  char  *m_pFileName;
  char  *m_pMapName;
  DWORD  m_dwSize;
  int    m_iCreateFlag;
private:
  void _Init();
  void _Destory();
public:
  void Create(char *szFileName, char *szMapName, DWORD dwSize);
  LPVOID GetBuffer();
  DWORD GetSize();
};

// Shared FileMap Client

class CSFMClient 
{
public:
  CSFMClient();
  virtual ~CSFMClient();
  CSFMClient(DWORD dwAccess, char *szMapName);
protected:
  HANDLE  m_hFileMap;
  LPVOID  m_lpFileMapBuffer;
  char  *m_pMapName;
  int    m_iOpenFlag;
private:
  void _Init();
  void _Destory();
public:
  void Open(DWORD dwAccess, char *szMapName);
  LPVOID GetBuffer();
  DWORD GetSize();
};
#endif // !defined(AFX_SFMSERVER_H__2D76A439_6388_4B07_AE7A_C82F458642ED__INCLUDED_)

//------------------------------------------------------

Tags:共享 内存 封装

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接