⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 ARP test mode. According to the idea we design the arithmetic for the key part, first the system sen
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "LANDetect.h"
#include "Login.h"
#include "MainFrm.h"
#include "DlgAdp.h"
#include "Auto.h"
#include "AddUser.h"
#include "EditPwd.h"
#include "Detect.h"
#include "Detail.h"
#include "Find.h"
#include "Log.h"
#include "Result.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
extern pcap_if_t *dev;

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_DETECT_NETSEG, OnDetectNetseg)
	ON_COMMAND(ID_OPERATE_START, OnOperateStart)
	ON_COMMAND(ID_START, OnStart)
	ON_COMMAND(ID_ADAPTER, OnAdapter)
	ON_COMMAND(ID_SET, OnSet)
	ON_COMMAND(ID_GRANT, OnGrant)
	ON_COMMAND(ID_EDITPWD, OnEditpwd)
	ON_WM_TIMER()
	ON_WM_CLOSE()
	ON_COMMAND(ID_DETECT_AUTO, OnDetectAuto)
	ON_COMMAND(ID_MANAGE_FIND, OnManageFind)
	ON_COMMAND(ID_MANAGE_DETAIL, OnManageDetail)
	ON_COMMAND(ID_MANAGE_ANALYZE, OnManageAnalyze)
	ON_COMMAND(ID_LOG, OnLog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CLOCK,
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	SetTimer(1,1000,NULL);       //用于显示当前时间
    //全局变量
	bmac="FF:FF:FF:FF:FF:FE";
	sec=30;
	check=true;
	frequency=0;
	type=0;
	f=0;
	f1=0;
	f2=0;
	sele=0;
	etime="10:00:00";
	m1[0]=m2[0]=172;
	m1[1]=m2[1]=29;
	m1[2]=m2[2]=5;
	m1[3]=2;
	m2[3]=50;
	CLogin dlg;
	dlg.DoModal();
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

void CMainFrame::OnOperateStart() 
{
	if(dev==NULL){
		MessageBox("请选择网卡!");
		return ;
	}
	CResult dlg;
	dlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers



void CMainFrame::OnDetectNetseg() 
{

	CDetect dlg;
	dlg.DoModal();
}

void CMainFrame::OnStart() 
{
	OnOperateStart();	
}

void CMainFrame::OnAdapter() 
{
	CDlgAdp dlg;
	dlg.DoModal();
}

void CMainFrame::OnSet() 
{
	CDetect dlg;
	dlg.DoModal();
	
}


void CMainFrame::OnGrant() 
{
	CAddUser dlg;
	dlg.DoModal();
	
}

void CMainFrame::OnEditpwd() 
{

	CEditPwd dlg;
	dlg.DoModal();
}

void CMainFrame::OnTimer(UINT nIDEvent) 
{
	SYSTEMTIME st = {0}; 
	GetLocalTime(&st);//获得当前本地时间
	CString time;
	time.Format("现在是:%d年%d月%d日 %d:%d:%d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
	m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK),time);
	int h,m,s;           //用于获取时间
	h=m=s=0;
	if(f)               //自动监测
	{
		if(f1)           //隔断监测
		{
			if(sele==0)
			{
				h=0;
				m=30;
				if((st.wMinute==0||st.wMinute==30)&&st.wSecond==0)
				{
					AfxMessageBox("系统自动监测启动!");
					if(dev==NULL)
					{
						CDlgAdp dlg;
						dlg.DoModal();
					}
					CResult dlg;
					dlg.DoModal();
				}
			}
			else
			{
				h=sele;
				m=0;
				if(st.wHour%h==0 &&st.wMinute==0 &&st.wSecond==0)        //测试成功
				{
					AfxMessageBox("系统自动监测启动!");
					if(dev==NULL)
					{
						CDlgAdp dlg;
						dlg.DoModal();
					}
					CResult dlg;
					dlg.DoModal();
				}
			}
		}
		if(f2)          //定时监测
		{
			CString hh,mm,ss;
			hh.Format("%c%c",etime.GetAt(0),etime.GetAt(1));
			mm.Format("%c%c",etime.GetAt(3),etime.GetAt(4));
			ss.Format("%c%c",etime.GetAt(6),etime.GetAt(7));
			if(st.wHour==atoi(LPCSTR(hh))&&st.wMinute==atoi(LPCSTR(mm))&&st.wSecond==atoi(LPCSTR(ss)))
			{
				AfxMessageBox("系统自动监测启动!");
				if(dev==NULL)
				{
					CDlgAdp dlg;
					dlg.DoModal();
				}
				CResult dlg;
				dlg.DoModal();
			}
		}
	}
	CFrameWnd::OnTimer(nIDEvent);
}

void CMainFrame::OnClose() 
{
	
	KillTimer(1);	
	CFrameWnd::OnClose();
}

void CMainFrame::OnDetectAuto() 
{
	CAuto dlg;
	dlg.DoModal();
}

void CMainFrame::OnManageFind() 
{
	CFind dlg;
	dlg.DoModal();
	
}

void CMainFrame::OnManageDetail() 
{
	CDetail dlg;
	dlg.DoModal();
	
}

void CMainFrame::OnManageAnalyze() 
{
	CLog dlg;
	dlg.DoModal();
	
}

void CMainFrame::OnLog() 
{
	CLog dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -