Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: resourcemeterwin9x.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of resourcemeterwin9x.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "resourcemeterwin9x.h"
  16. #include "..\..\LgLib\Version.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. CResourceMeterWin9x::CResourceMeterWin9x()
  23. {
  24. m_hLibrary = NULL;
  25. m_pGetRes = NULL;
  26. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::CResourceMeterWin9x") );
  27. }
  28. CResourceMeterWin9x::~CResourceMeterWin9x()
  29. {
  30. Destroy();
  31. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::~CResourceMeterWin9x") );
  32. }
  33. /*
  34. if(!m_Flags.bDebugMode)
  35. sprintf(pBuffer, "%02d\\%02d\\%04d %02d:%02d:%02d", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);
  36. else
  37. {
  38. CHAR pRes[0x50];
  39. if(m_hRSRC)
  40. {
  41. typedef LONG (CALLBACK* GETRES)(int);
  42. GETRES lpfnGetRes = (GETRES)::GetProcAddress(m_hRSRC, "_MyGetFreeSystemResources32@4");
  43. if(lpfnGetRes)
  44. {
  45. const GFSR_SYSTEMRESOURCES = 0;
  46. const GFSR_GDIRESOURCES = 1;
  47. const GFSR_USERRESOURCES = 2;
  48. long lSysRes = (*lpfnGetRes)(GFSR_SYSTEMRESOURCES);
  49. long lGdiRes = (*lpfnGetRes)(GFSR_GDIRESOURCES);
  50. long lUsrRes = (*lpfnGetRes)(GFSR_USERRESOURCES);
  51. sprintf(pRes, ", Sys=%d%%, Gdi=%d%%, User=%d%%", lSysRes, lGdiRes, lUsrRes);
  52. }
  53. }
  54. MEMORYSTATUS ms;
  55. ::GlobalMemoryStatus(&ms);
  56. sprintf(pBuffer, "%02d\\%02d\\%04d %02d:%02d:%02d"
  57. " %02lu%% free, phis=%luKb, page=%luKb, virt=%luKb%s lgs=%d SN=%02X%02X%02X%02X%02X", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond,
  58. 100-ms.dwMemoryLoad, ms.dwAvailPhys / 1024, ms.dwAvailPageFile / 1024, ms.dwAvailVirtual / 1024, pRes, m_Classes.pProfile->PtzPanShift(),
  59. (DWORD)m_Classes.pProfile->PtzSN()[0],
  60. (DWORD)m_Classes.pProfile->PtzSN()[1],
  61. (DWORD)m_Classes.pProfile->PtzSN()[2],
  62. (DWORD)m_Classes.pProfile->PtzSN()[3],
  63. (DWORD)m_Classes.pProfile->PtzSN()[4] );
  64. } // end of else
  65. ::SetWindowText(m_hWnd, pBuffer);
  66. */
  67. BOOL CResourceMeterWin9x::Create()
  68. {
  69. Destroy();
  70. __try
  71. {
  72. m_hLibrary = LoadLibrary( _T("RSRC32.DLL") );
  73. if( !m_hLibrary )
  74. {
  75. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("LoadLibrary failed") );
  76. return FALSE;
  77. }
  78. m_pGetRes = (GETRES)::GetProcAddress( m_hLibrary, "_MyGetFreeSystemResources32@4" );
  79. if( !m_pGetRes )
  80. {
  81. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("GetProcAddress failed") );
  82. return FALSE;
  83. }
  84. }
  85. __except(1)
  86. {
  87. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("Exception 0x%08X"), _exception_code() );
  88. return FALSE;
  89. }
  90. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::Create"), _T("Succeeded") );
  91. return TRUE;
  92. }
  93. void CResourceMeterWin9x::Destroy()
  94. {
  95. __try
  96. {
  97. if( m_hLibrary )
  98. ::FreeLibrary( m_hLibrary );
  99. }
  100. __except(1)
  101. {
  102. }
  103. m_hLibrary = NULL;
  104. m_pGetRes = NULL;
  105. }
  106. LONG CResourceMeterWin9x::GetSystemResources()
  107. {
  108. __try
  109. {
  110. return m_pGetRes ? (*m_pGetRes)(GFSR_SYSTEMRESOURCES) : -1;
  111. }
  112. __except(1)
  113. {
  114. return -1;
  115. }
  116. }
  117. LONG CResourceMeterWin9x::GetUserResources()
  118. {
  119. __try
  120. {
  121. return m_pGetRes ? (*m_pGetRes)(GFSR_USERRESOURCES) : -1;
  122. }
  123. __except(1)
  124. {
  125. return -1;
  126. }
  127. }
  128. LONG CResourceMeterWin9x::GetGDIResources()
  129. {
  130. __try
  131. {
  132. return m_pGetRes ? (*m_pGetRes)(GFSR_GDIRESOURCES) : -1;
  133. }
  134. __except(1)
  135. {
  136. return -1;
  137. }
  138. }