rainmeter-studio/Library/MeasureNet.h

80 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:
2012-04-09 16:45:54 +00:00
virtual UINT GetTypeID() { return TypeID<CMeasureNet>(); }
2009-02-10 18:37:48 +00:00
static void UpdateIFTable();
static void UpdateStats();
static void ResetStats();
2012-05-20 13:12:13 +00:00
static void ReadStats(const std::wstring& 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:
2012-10-09 15:33:49 +00:00
enum NET
{
NET_IN,
NET_OUT,
NET_TOTAL
};
2012-10-09 15:33:49 +00:00
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name, NET type);
virtual ~CMeasureNet();
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private:
ULONG64 GetNetOctets(NET net);
ULONG64 GetNetStatsValue(NET net);
2009-02-10 18:37:48 +00:00
2012-10-09 15:33:49 +00:00
NET m_Net;
2009-02-10 18:37:48 +00:00
UINT m_Interface;
2012-10-09 15:33:49 +00:00
ULONG64 m_Octets;
bool m_FirstTime;
2009-02-10 18:37:48 +00:00
bool m_Cumulative;
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