rainmeter-studio/Library/MeasureNet.h

75 lines
2.1 KiB
C
Raw Normal View History

2009-02-10 18:37:48 +00:00
/*
Copyright (C) 2001 Kimmo Pekkola
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2009-02-10 18:37:48 +00:00
*/
#ifndef __MEASURENET_H__
#define __MEASURENET_H__
2011-03-29 21:19:02 +00:00
#include <winsock2.h>
#include <ws2tcpip.h>
2011-02-07 08:10:47 +00:00
#include <Iphlpapi.h>
2011-03-29 21:19:02 +00:00
#include "Measure.h"
typedef NETIO_STATUS (NETIOAPI_API_ * FPGETIFTABLE2)(PMIB_IF_TABLE2* Table);
2011-08-02 01:20:05 +00:00
typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
2009-02-10 18:37:48 +00:00
class CMeasureNet : public CMeasure
{
public:
enum NET {
NET_IN,
NET_OUT,
NET_TOTAL
};
2011-02-15 16:26:54 +00:00
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name);
2009-02-10 18:37:48 +00:00
virtual ~CMeasureNet();
virtual bool Update();
static void UpdateIFTable();
static void UpdateStats();
static void ResetStats();
static void ReadStats(const WCHAR* iniFile, std::wstring& statsDate);
2011-12-09 19:49:06 +00:00
static void WriteStats(const WCHAR* iniFile, const std::wstring& statsDate);
2009-02-10 18:37:48 +00:00
static void InitializeNewApi();
static void FinalizeNewApi();
2009-02-10 18:37:48 +00:00
protected:
void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
ULONG64 GetNetOctets(NET net);
ULONG64 GetNetStatsValue(NET net);
2009-02-10 18:37:48 +00:00
double m_CurrentTraffic;
double m_TrafficValue;
UINT m_Interface;
bool m_Cumulative;
std::wstring m_TrafficAction;
static std::vector<ULONG64> c_OldStatValues;
static std::vector<ULONG64> c_StatValues;
static BYTE* c_Table;
2009-02-10 18:37:48 +00:00
static UINT c_NumOfTables;
static FPGETIFTABLE2 c_GetIfTable2;
2011-08-02 01:20:05 +00:00
static FPFREEMIBTABLE c_FreeMibTable;
2009-02-10 18:37:48 +00:00
};
#endif