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
164 lines
3.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: resourcemeterwin9x.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of resourcemeterwin9x.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "resourcemeterwin9x.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
CResourceMeterWin9x::CResourceMeterWin9x()
|
|
{
|
|
m_hLibrary = NULL;
|
|
m_pGetRes = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::CResourceMeterWin9x") );
|
|
}
|
|
|
|
CResourceMeterWin9x::~CResourceMeterWin9x()
|
|
{
|
|
Destroy();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::~CResourceMeterWin9x") );
|
|
}
|
|
|
|
/*
|
|
if(!m_Flags.bDebugMode)
|
|
sprintf(pBuffer, "%02d\\%02d\\%04d %02d:%02d:%02d", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond);
|
|
else
|
|
{
|
|
CHAR pRes[0x50];
|
|
|
|
if(m_hRSRC)
|
|
{
|
|
typedef LONG (CALLBACK* GETRES)(int);
|
|
|
|
GETRES lpfnGetRes = (GETRES)::GetProcAddress(m_hRSRC, "_MyGetFreeSystemResources32@4");
|
|
|
|
if(lpfnGetRes)
|
|
{
|
|
const GFSR_SYSTEMRESOURCES = 0;
|
|
const GFSR_GDIRESOURCES = 1;
|
|
const GFSR_USERRESOURCES = 2;
|
|
|
|
long lSysRes = (*lpfnGetRes)(GFSR_SYSTEMRESOURCES);
|
|
long lGdiRes = (*lpfnGetRes)(GFSR_GDIRESOURCES);
|
|
long lUsrRes = (*lpfnGetRes)(GFSR_USERRESOURCES);
|
|
|
|
sprintf(pRes, ", Sys=%d%%, Gdi=%d%%, User=%d%%", lSysRes, lGdiRes, lUsrRes);
|
|
}
|
|
}
|
|
|
|
MEMORYSTATUS ms;
|
|
::GlobalMemoryStatus(&ms);
|
|
|
|
sprintf(pBuffer, "%02d\\%02d\\%04d %02d:%02d:%02d"
|
|
" %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,
|
|
100-ms.dwMemoryLoad, ms.dwAvailPhys / 1024, ms.dwAvailPageFile / 1024, ms.dwAvailVirtual / 1024, pRes, m_Classes.pProfile->PtzPanShift(),
|
|
(DWORD)m_Classes.pProfile->PtzSN()[0],
|
|
(DWORD)m_Classes.pProfile->PtzSN()[1],
|
|
(DWORD)m_Classes.pProfile->PtzSN()[2],
|
|
(DWORD)m_Classes.pProfile->PtzSN()[3],
|
|
(DWORD)m_Classes.pProfile->PtzSN()[4] );
|
|
} // end of else
|
|
|
|
::SetWindowText(m_hWnd, pBuffer);
|
|
*/
|
|
|
|
|
|
BOOL CResourceMeterWin9x::Create()
|
|
{
|
|
Destroy();
|
|
|
|
__try
|
|
{
|
|
m_hLibrary = LoadLibrary( _T("RSRC32.DLL") );
|
|
if( !m_hLibrary )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("LoadLibrary failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
m_pGetRes = (GETRES)::GetProcAddress( m_hLibrary, "_MyGetFreeSystemResources32@4" );
|
|
if( !m_pGetRes )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("GetProcAddress failed") );
|
|
return FALSE;
|
|
}
|
|
}
|
|
__except(1)
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CResourceMeterWin9x::Create"), _T("Exception 0x%08X"), _exception_code() );
|
|
return FALSE;
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CResourceMeterWin9x::Create"), _T("Succeeded") );
|
|
return TRUE;
|
|
}
|
|
|
|
void CResourceMeterWin9x::Destroy()
|
|
{
|
|
__try
|
|
{
|
|
if( m_hLibrary )
|
|
::FreeLibrary( m_hLibrary );
|
|
}
|
|
__except(1)
|
|
{
|
|
|
|
}
|
|
|
|
m_hLibrary = NULL;
|
|
m_pGetRes = NULL;
|
|
}
|
|
|
|
LONG CResourceMeterWin9x::GetSystemResources()
|
|
{
|
|
__try
|
|
{
|
|
return m_pGetRes ? (*m_pGetRes)(GFSR_SYSTEMRESOURCES) : -1;
|
|
}
|
|
__except(1)
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
LONG CResourceMeterWin9x::GetUserResources()
|
|
{
|
|
__try
|
|
{
|
|
return m_pGetRes ? (*m_pGetRes)(GFSR_USERRESOURCES) : -1;
|
|
}
|
|
__except(1)
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
LONG CResourceMeterWin9x::GetGDIResources()
|
|
{
|
|
__try
|
|
{
|
|
return m_pGetRes ? (*m_pGetRes)(GFSR_GDIRESOURCES) : -1;
|
|
}
|
|
__except(1)
|
|
{
|
|
return -1;
|
|
}
|
|
}
|