ShardMainWinHandle.cpp 908 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "StdAfx.h"
  2. #include "ShardMainWinHandle.h"
  3. CShardMainWinHandle::CShardMainWinHandle(void)
  4. {
  5. m_hMapFile= CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0,1024,_T("smart_evaluation_main_window_handle"));
  6. m_pBaseMapFile=MapViewOfFile(m_hMapFile,FILE_MAP_READ|FILE_MAP_WRITE,0,0,0);
  7. //HANDLE m_hMapFile =OpenFileMapping(FILE_MAP_WRITE,FALSE,_T("smart_evaluation_main_window_handle"));
  8. }
  9. CShardMainWinHandle::~CShardMainWinHandle(void)
  10. {
  11. if (m_pBaseMapFile) {
  12. UnmapViewOfFile(m_pBaseMapFile);
  13. m_pBaseMapFile =NULL;
  14. }
  15. CloseHandle(m_hMapFile);
  16. }
  17. BOOL CShardMainWinHandle::SaveWndHandle( HWND hWnd )
  18. {
  19. if(m_pBaseMapFile){
  20. *(HWND*) m_pBaseMapFile =hWnd;
  21. return TRUE;
  22. }
  23. return FALSE;
  24. }
  25. BOOL CShardMainWinHandle::GetWndHandle( HWND& hWnd )
  26. {
  27. if(m_pBaseMapFile){
  28. hWnd = *(HWND*) m_pBaseMapFile;
  29. return TRUE;
  30. }
  31. return FALSE;
  32. }
  33. CShardMainWinHandle g_ShardMainWinHandle;