CWinSharedMemory Class Reference

#include <WinSMTool.h>

List of all members.

Public Member Functions

 CWinSharedMemory (void)
 CWinSharedMemory (const char *name)
 CWinSharedMemory (const char *name, int size=1024, BOOL create=FALSE)
virtual ~CWinSharedMemory (void)

Protected Member Functions

void createMap ()
void get ()
void put ()

Protected Attributes

HANDLE m_hMapping = NULL
void * m_pMappingView = NULL
CMutex * m_pMutex = NULL

Detailed Description

Definition at line 18 of file WinSMTool.h.


Constructor & Destructor Documentation

CWinSharedMemory ( void   ) 

Definition at line 9 of file WinSMTool.cpp.

References JBXWL_DEFAULT_SMNAME.

00010 {
00011     CWinSharedMemory(JBXWL_DEFAULT_SMNAME, 1024, FALSE);
00012 }

CWinSharedMemory ( const char *  name  ) 
CWinSharedMemory ( const char *  name,
int  size = 1024,
BOOL  create = FALSE 
)

Definition at line 16 of file WinSMTool.cpp.

References CWinSharedMemory::m_hMapping, CWinSharedMemory::m_pMappingView, CWinSharedMemory::m_pMutex, and jbxwl::mbs2ts().

00017 {
00018     m_hMapping = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, mbs2ts((char*)name));
00019 
00020     if (m_hMapping == NULL && create) {
00021         // メモリマップドファイルの生成
00022         m_hMapping = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, mbs2ts((char*)name));
00023     }
00024 
00025     if (m_hMapping != NULL) {
00026         // プロセス内のアドレス空間にファイルのビューをマップ
00027         m_pMappingView = ::MapViewOfFile(m_hMapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
00028 
00029         // ミューテックスオブジェクトの生成
00030         m_pMutex = new CMutex(FALSE, mbs2ts((char*)name)+mbs2ts("_mutex"));
00031     }
00032 }

Here is the call graph for this function:

~CWinSharedMemory ( void   )  [virtual]

Definition at line 36 of file WinSMTool.cpp.

References CWinSharedMemory::m_hMapping, CWinSharedMemory::m_pMappingView, and CWinSharedMemory::m_pMutex.

00037 {
00038     BOOL b = ::UnmapViewOfFile(m_pMappingView);
00039     ::CloseHandle(m_hMapping);
00040 
00041     delete m_pMutex;
00042 }


Member Function Documentation

void createMap (  )  [protected]
void get (  )  [protected]

Definition at line 54 of file WinSMTool.cpp.

References CWinSharedMemory::m_pMutex.

00055 {
00056     // 共有メモリの内容を取得
00057     m_pMutex->Lock(INFINITE);
00058     //m_strEdit1 = (LPTSTR)m_pMappingView;
00059     m_pMutex->Unlock();
00060 
00061     //UpdateData(FALSE);
00062 }

void put (  )  [protected]

Definition at line 66 of file WinSMTool.cpp.

References CWinSharedMemory::m_pMutex.

00067 {
00068     //UpdateData(TRUE);
00069 
00070     // 共有メモリへ書き込む
00071     m_pMutex->Lock(INFINITE);
00072     //memcpy(m_pMappingView, (LPCTSTR)m_strEdit1, m_strEdit1.GetLength() + 1);
00073     m_pMutex->Unlock();
00074 }


Member Data Documentation

HANDLE m_hMapping = NULL [protected]
void* m_pMappingView = NULL [protected]
CMutex* m_pMutex = NULL [protected]

The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Win_Lib by  doxygen 1.6.1