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

📄 ipmondlg.h

📁 局域网来访者IP监视以及文件修改监视: 1.监听常用的局域网访问工具
💻 H
字号:
// ipmonDlg.h : header file
//

#if !defined(AFX_IPMONDLG_H__47076949_0324_11D5_924F_00010219EDF4__INCLUDED_)
#define AFX_IPMONDLG_H__47076949_0324_11D5_924F_00010219EDF4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
CString GetNowTime();

typedef struct _PROTN2T
{ 
	int  proto ;
	char *pprototext ;
}PROTN2T ; 
						
#define PROTO_NUM  11 

/* The IP header */
typedef struct _IPHEADER {
        unsigned char  header_len:4;
        unsigned char  version:4;   
        unsigned char  tos;            // type of service
        unsigned short total_len;      // length of the packet
        unsigned short ident;          // unique identifier
        unsigned short flags;          
        unsigned char  ttl;            
        unsigned char  proto;          // protocol ( IP , TCP, UDP etc)
        unsigned short checksum;       
        unsigned int   sourceIP;
        unsigned int   destIP;

}IPHEADER;

/*-------------------zhuwei add(2002.11.9)-----------------------------*/


#define UDP_HEAD_LEN 8	/* UDP head length */

#define PSEUDO_HEAD_LEN 12	/* Pseudo head length */

#define ICMP_HEAD_LEN 4	/* ICMP head length */

struct TCPPacketHead {
	WORD SourPort;
	WORD DestPort;
	DWORD SeqNo;
	DWORD AckNo;
	BYTE HLen;
	BYTE Flag;
	WORD WndSize;
	WORD ChkSum;
	WORD UrgPtr;
};

struct ICMPPacketHead {
	BYTE Type;
	BYTE Code;
	WORD ChkSum;
};

struct UDPPacketHead {
	WORD SourPort;
	WORD DestPort;
	WORD Len;
	WORD ChkSum;
};

#include "DirectoryChanges.h"
class CDirectoryChangeHandler_ListBox : public CDirectoryChangeHandler
{
public:
	CDirectoryChangeHandler_ListBox(CListCtrl & list_box)
		: CDirectoryChangeHandler(),
		m_listBox( list_box ){}
	protected:
	//These functions are called when the directory to watch has had a change made to it

	void AddData(CString s0, CString s1)
	{  
		int index;
		index = m_listBox.InsertItem(0,s0);
		m_listBox.SetItem(index,1,LVIF_TEXT,s1, 0, 0, 0,0);
	}
	void On_FileAdded(const CString & strFileName)
	{
		CString strTime;
		strTime = GetNowTime();
	//	m_listBox.InsertItem(0,strTime + _T("  添加文件: ") + strFileName);
		AddData(strTime, _T("添加文件: ") + strFileName);
	}
	void On_FileRemoved(const CString & strFileName)
	{
		CString strTime;
		strTime = GetNowTime();
	//	m_listBox.InsertItem(0,strTime + _T("  删除文件: ") + strFileName);
		AddData(strTime, _T("删除文件: ") + strFileName);
	}
	void On_FileModified(const CString & strFileName)
	{
		CString strTime;
		strTime = GetNowTime();
	//	m_listBox.InsertItem(0,strTime + _T("  修改文件: ") + strFileName);
		AddData(strTime, _T("修改文件: ") + strFileName);
	}
	void On_FileNameChanged(const CString & strOldFileName, const CString & strNewFileName)
	{
		CString strTime;
		strTime = GetNowTime();
	//	m_listBox.InsertItem(0,strTime + _T("  重命名文件: ") + strOldFileName + _T(" 为: ") + strNewFileName);
		AddData(strTime, _T("重命名文件: ") + strOldFileName + _T(" 为: ") + strNewFileName);
	}

	void On_WatchStarted(DWORD dwError, const CString & strDirectoryName)
	{
		CString strTime;
		strTime = GetNowTime();
		if( dwError == 0 )
		{
		//	m_listBox.InsertItem(0,strTime + _T("  开始监视文件夹: ") + strDirectoryName);
			AddData(strTime, _T("开始监视文件夹: ") + strDirectoryName);
		}
		else
		{
		//	m_listBox.InsertItem(0,strTime + _T("  监视文件夹失败: ") + strDirectoryName);
			AddData(strTime, _T("监视文件夹失败: ") + strDirectoryName);
		}
	}
	void On_WatchStopped(const CString & strDirectoryName)
	{
		//
		//	NOTE:  Be careful ! On_WatchStopped can be called AFTER this list box has
		//	been destoroyed.  Be carefull whenever interacting w/ windows with this function
		//	because the window may not be valid when this function is executed for the last time.
		//
		//
		if( ::IsWindow( m_listBox.GetSafeHwnd() ) )
		{
		//	m_listBox.InsertItem(0,_T("Stopped watching directory: ") + strDirectoryName);
			CString strTime;
			strTime = GetNowTime();
			AddData(strTime, _T("监视文件夹失败: ") + strDirectoryName);
		}
		else
		{
			TRACE(_T("NOTE: m_listBox is not a valid window! This has probably been called as the result of program shutdown sometime after CDirWatcherDlg::OnBtnMonitor2() was used to watch a direcotry.\n"));
			TRACE(_T("NOTE: Be sure that you are careful in your implementation of this function to watch out for the same condition if you are dealing w/ windows.\n"));
//			MessageBeep(static_cast<UINT>(-1));
//			MessageBeep(static_cast<UINT>(-1));
//			MessageBeep(static_cast<UINT>(-1));
			
			//
			//	See the comments in DirectoryChanges.h for the CDirectoryChangeHandler::On_WatchStopped() function.
			//
			//
		}
	}

	CListCtrl & m_listBox;

};

/////////////////////////////////////////////////////////////////////////////
// CIpmonDlg dialog

class CIpmonDlg : public CDialog
{
// Construction
public:
//	void AddData(CString s0,CString s1,CString s2,CString s3,CString s4,CString s5,CString s6,CString s7, CString s8);
	void AddData(CString s0, CString s1, CString s2);
	CIpmonDlg(CWnd* pParent = NULL);	// standard constructor
	
	
	DWORD GetChangeFlags1();
	CDirectoryChangeWatcher m_DirWatcher;
	CDirectoryChangeHandler_ListBox m_DirChangeHandler;

// Dialog Data
	//{{AFX_DATA(CIpmonDlg)
	enum { IDD = IDD_IPMON_DIALOG };
	CListCtrl	m_lstChanges;
	CListCtrl	m_ctrList;
	CButton	m_start;
	CString	m_strDirectoryToMonitor;
	CString	m_strDirectoryToMonitor2;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CIpmonDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	DWORD  m_ipsource     ; // IP in net format
	DWORD  m_iphostsource ; // same IP in host format
	DWORD  m_iphost;
	DWORD  m_ipcheckedhost;
	SOCKET m_s            ;
	DWORD  m_threadID     ;
	BOOL   m_Multihomed   ;
	BOOL   m_Local        ;
	CDWordArray m_IPArr   ;

	friend UINT threadFunc ( LPVOID p ) ;


	// Generated message map functions
	//{{AFX_MSG(CIpmonDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnLookUp();
	virtual void OnOK();
	afx_msg void OnBtnMonitor();
	afx_msg void OnBtnBrowse1();
	afx_msg void OnBtnMonitor2();
	afx_msg void OnBtnBrowse2();
	afx_msg void OnBtnClearip();
	afx_msg void OnBtnClearlistfile();
	afx_msg void OnClose();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_IPMONDLG_H__47076949_0324_11D5_924F_00010219EDF4__INCLUDED_)

⌨️ 快捷键说明

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