• 大小: 133KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C/C++
  • 标签: c++  源码  vs2010  

资源简介

修改Windows路由表的程序,实现了对路由表的查询、添加、编辑、删除功能。开发环境VS2010,C++语言

资源截图

代码片段和文件信息

// ModifyRoute.cpp : 实现文件
//

#include “stdafx.h“
#include “WinRouter.h“
#include “ModifyRoute.h“
#include “afxdialogex.h“


// ModifyRoute 对话框

IMPLEMENT_DYNAMIC(ModifyRoute CDialogEx)

ModifyRoute::ModifyRoute(CWnd* pParent /*=NULL*/)
: CDialogEx(ModifyRoute::IDD pParent)
// m_distination(_T(““))
 m_subnetMask(_T(““))
 m_nextHop(_T(““))
{

m_destination = _T(““);
}

ModifyRoute::~ModifyRoute()
{
}

void ModifyRoute::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
//  DDX_Text(pDX IDC_EDIT1 m_distination);
DDX_Text(pDX IDC_EDIT2 m_subnetMask);
DDX_Text(pDX IDC_EDIT3 m_nextHop);
DDX_Text(pDX IDC_EDIT1 m_destination);
}


BEGIN_MESSAGE_MAP(ModifyRoute CDialogEx)
ON_BN_CLICKED(IDOK &ModifyRoute::OnBnClickedOk)
END_MESSAGE_MAP()


// ModifyRoute 消息处理程序

void ModifyRoute::SetInit(bool blIsAdd int iRouteIndex 
PMIB_IPFORWARDTABLE pIpForwardTable DWORD dwMaxInterfaceMetric 
DWORD dwDefaultInterface)
{
m_blIsAdd = blIsAdd;
m_iRouteIndex = iRouteIndex;
m_pIpForwardTable = pIpForwardTable;
m_dwMaxInterfaceMetric = dwMaxInterfaceMetric;
m_dwDefaultInterface = dwDefaultInterface;
}

void ModifyRoute::LoadData()
{
IN_ADDR inDestination inSubnetMask inNextHop;
inDestination.S_un.S_addr = m_pIpForwardTable->table[m_iRouteIndex].dwForwardDest;
inSubnetMask.S_un.S_addr = m_pIpForwardTable->table[m_iRouteIndex].dwForwardMask;
inNextHop.S_un.S_addr = m_pIpForwardTable->table[m_iRouteIndex].dwForwardNextHop;

wstring wstrTmp;
Ascii2WideString(inet_ntoa(inDestination) wstrTmp);
m_destination = wstrTmp.c_str();
Ascii2WideString(inet_ntoa(inSubnetMask) wstrTmp);
m_subnetMask = wstrTmp.c_str();
Ascii2WideString(inet_ntoa(inNextHop) wstrTmp);
m_nextHop = wstrTmp.c_str();
UpdateData(FALSE);
}

BOOL ModifyRoute::OnInitDialog()
{
CDialogEx::OnInitDialog();

// TODO:  在此添加额外的初始化
if(m_blIsAdd) {
//LoadData();
SetWindowText(_T(“添加路由“));
} else {
LoadData();
SetWindowText(_T(“编辑路由“));
}
return TRUE;  // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}


void ModifyRoute::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);

DWORD dwDestination dwSubnetMask dwNextHop;
CStringA csaDestination = CStringA(m_destination);
CStringA csaSubnetMask = CStringA(m_subnetMask);
CStringA csaNextHop = CStringA(m_nextHop);
dwDestination = inet_addr(csaDestination.GetBuffer());
dwSubnetMask = inet_addr(csaSubnetMask.GetBuffer());
dwNextHop = inet_addr(csaNextHop.GetBuffer());

MIB_IPFORWARDROW mibIpForwardRow = {0};
DWORD e;
if(m_blIsAdd) {
mibIpForwardRow.dwForwardMetric1 = m_dwMaxInterfaceMetric;
mibIpForwardRow.dwForwardDest = dwDestination;
mibIpForwardRow.dwForwardMask = dwSubnetMask;
mibIpForwardRow.dwForwardNextHop = dwNextHop;
mibIpForwardRow.dwForwardIfIndex = m_dwDefaultInterface;
//mibIpForwardRow.dwForwardType = 4;
mibIpFor

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4241  2012-04-25 14:01  WinRouter\WinRouter\ModifyRoute.cpp

     文件        851  2012-04-25 14:02  WinRouter\WinRouter\ModifyRoute.h

     文件       3051  2012-04-21 22:27  WinRouter\WinRouter\ReadMe.txt

    .......     67777  2009-08-31 02:31  WinRouter\WinRouter\res\WinRouter.ico

     文件        674  2012-04-21 22:27  WinRouter\WinRouter\res\WinRouter.rc2

     文件       1822  2012-04-22 02:32  WinRouter\WinRouter\resource.h

     文件        142  2012-04-21 22:27  WinRouter\WinRouter\stdafx.cpp

     文件       2233  2012-04-21 23:59  WinRouter\WinRouter\stdafx.h

     文件        234  2012-04-21 22:27  WinRouter\WinRouter\targetver.h

     文件     105636  2012-04-22 02:34  WinRouter\WinRouter\WinRouter.aps

     文件       2032  2012-04-21 22:27  WinRouter\WinRouter\WinRouter.cpp

     文件        460  2012-04-21 22:27  WinRouter\WinRouter\WinRouter.h

     文件      10564  2012-04-22 02:34  WinRouter\WinRouter\WinRouter.rc

     文件       6023  2012-04-25 01:44  WinRouter\WinRouter\WinRouter.vcxproj

     文件       2190  2012-04-25 01:44  WinRouter\WinRouter\WinRouter.vcxproj.filters

     文件        143  2012-04-21 22:26  WinRouter\WinRouter\WinRouter.vcxproj.user

     文件       8050  2012-04-25 14:21  WinRouter\WinRouter\WinRouterDlg.cpp

     文件       1046  2012-04-25 14:07  WinRouter\WinRouter\WinRouterDlg.h

     文件        894  2012-04-21 22:27  WinRouter\WinRouter.sln

    ..A..H.     14848  2012-04-25 14:28  WinRouter\WinRouter.suo

     目录          0  2012-04-21 22:27  WinRouter\WinRouter\res

     目录          0  2012-04-25 14:16  WinRouter\WinRouter

     目录          0  2012-04-25 14:16  WinRouter

----------- ---------  ---------- -----  ----

               232911                    23


评论

共有 条评论